2024-01-28 13:10:56 -07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause */
|
2014-09-26 15:21:21 -07:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2011, 2012, Atheros Communications Inc.
|
|
|
|
* Copyright (c) 2014, I2SE GmbH
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Atheros Ethernet framing. Every Ethernet frame is surrounded by an atheros
|
|
|
|
* frame while transmitted over a serial channel.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _QCA_FRAMING_H
|
|
|
|
#define _QCA_FRAMING_H
|
|
|
|
|
|
|
|
#include <linux/if_ether.h>
|
|
|
|
#include <linux/if_vlan.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
|
|
|
|
/* Frame is currently being received */
|
|
|
|
#define QCAFRM_GATHER 0
|
|
|
|
|
|
|
|
/* No header byte while expecting it */
|
|
|
|
#define QCAFRM_NOHEAD (QCAFRM_ERR_BASE - 1)
|
|
|
|
|
|
|
|
/* No tailer byte while expecting it */
|
|
|
|
#define QCAFRM_NOTAIL (QCAFRM_ERR_BASE - 2)
|
|
|
|
|
|
|
|
/* Frame length is invalid */
|
|
|
|
#define QCAFRM_INVLEN (QCAFRM_ERR_BASE - 3)
|
|
|
|
|
|
|
|
/* Frame length is invalid */
|
|
|
|
#define QCAFRM_INVFRAME (QCAFRM_ERR_BASE - 4)
|
|
|
|
|
ethernet: use core min/max MTU checking
et131x: min_mtu 64, max_mtu 9216
altera_tse: min_mtu 64, max_mtu 1500
amd8111e: min_mtu 60, max_mtu 9000
bnad: min_mtu 46, max_mtu 9000
macb: min_mtu 68, max_mtu 1500 or 10240 depending on hardware capability
xgmac: min_mtu 46, max_mtu 9000
cxgb2: min_mtu 68, max_mtu 9582 (pm3393) or 9600 (vsc7326)
enic: min_mtu 68, max_mtu 9000
gianfar: min_mtu 50, max_mu 9586
hns_enet: min_mtu 68, max_mtu 9578 (v1) or 9706 (v2)
ksz884x: min_mtu 60, max_mtu 1894
myri10ge: min_mtu 68, max_mtu 9000
natsemi: min_mtu 64, max_mtu 2024
nfp: min_mtu 68, max_mtu hardware-specific
forcedeth: min_mtu 64, max_mtu 1500 or 9100, depending on hardware
pch_gbe: min_mtu 46, max_mtu 10300
pasemi_mac: min_mtu 64, max_mtu 9000
qcaspi: min_mtu 46, max_mtu 1500
- remove qcaspi_netdev_change_mtu as it is now redundant
rocker: min_mtu 68, max_mtu 9000
sxgbe: min_mtu 68, max_mtu 9000
stmmac: min_mtu 46, max_mtu depends on hardware
tehuti: min_mtu 60, max_mtu 16384
- driver had no max mtu checking, but product docs say 16k jumbo packets
are supported by the hardware
netcp: min_mtu 68, max_mtu 9486
- remove netcp_ndo_change_mtu as it is now redundant
via-velocity: min_mtu 64, max_mtu 9000
octeon: min_mtu 46, max_mtu 65370
CC: netdev@vger.kernel.org
CC: Mark Einon <mark.einon@gmail.com>
CC: Vince Bridgers <vbridger@opensource.altera.com>
CC: Rasesh Mody <rasesh.mody@qlogic.com>
CC: Nicolas Ferre <nicolas.ferre@atmel.com>
CC: Santosh Raspatur <santosh@chelsio.com>
CC: Hariprasad S <hariprasad@chelsio.com>
CC: Christian Benvenuti <benve@cisco.com>
CC: Sujith Sankar <ssujith@cisco.com>
CC: Govindarajulu Varadarajan <_govind@gmx.com>
CC: Neel Patel <neepatel@cisco.com>
CC: Claudiu Manoil <claudiu.manoil@freescale.com>
CC: Yisen Zhuang <yisen.zhuang@huawei.com>
CC: Salil Mehta <salil.mehta@huawei.com>
CC: Hyong-Youb Kim <hykim@myri.com>
CC: Jakub Kicinski <jakub.kicinski@netronome.com>
CC: Olof Johansson <olof@lixom.net>
CC: Jiri Pirko <jiri@resnulli.us>
CC: Byungho An <bh74.an@samsung.com>
CC: Girish K S <ks.giri@samsung.com>
CC: Vipul Pandya <vipul.pandya@samsung.com>
CC: Giuseppe Cavallaro <peppe.cavallaro@st.com>
CC: Alexandre Torgue <alexandre.torgue@st.com>
CC: Andy Gospodarek <andy@greyhouse.net>
CC: Wingman Kwok <w-kwok2@ti.com>
CC: Murali Karicheri <m-karicheri2@ti.com>
CC: Francois Romieu <romieu@fr.zoreil.com>
Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-10-17 12:54:17 -07:00
|
|
|
/* Min/Max Ethernet MTU: 46/1500 */
|
2017-05-29 04:57:14 -07:00
|
|
|
#define QCAFRM_MIN_MTU (ETH_ZLEN - ETH_HLEN)
|
|
|
|
#define QCAFRM_MAX_MTU ETH_DATA_LEN
|
2014-09-26 15:21:21 -07:00
|
|
|
|
|
|
|
/* Min/Max frame lengths */
|
2017-05-29 04:57:14 -07:00
|
|
|
#define QCAFRM_MIN_LEN (QCAFRM_MIN_MTU + ETH_HLEN)
|
|
|
|
#define QCAFRM_MAX_LEN (QCAFRM_MAX_MTU + VLAN_ETH_HLEN)
|
2014-09-26 15:21:21 -07:00
|
|
|
|
|
|
|
/* QCA7K header len */
|
|
|
|
#define QCAFRM_HEADER_LEN 8
|
|
|
|
|
|
|
|
/* QCA7K footer len */
|
|
|
|
#define QCAFRM_FOOTER_LEN 2
|
|
|
|
|
|
|
|
/* QCA7K Framing. */
|
|
|
|
#define QCAFRM_ERR_BASE -1000
|
|
|
|
|
|
|
|
enum qcafrm_state {
|
2017-05-29 04:57:19 -07:00
|
|
|
/* HW length is only available on SPI */
|
2014-09-26 15:21:21 -07:00
|
|
|
QCAFRM_HW_LEN0 = 0x8000,
|
|
|
|
QCAFRM_HW_LEN1 = QCAFRM_HW_LEN0 - 1,
|
|
|
|
QCAFRM_HW_LEN2 = QCAFRM_HW_LEN1 - 1,
|
|
|
|
QCAFRM_HW_LEN3 = QCAFRM_HW_LEN2 - 1,
|
|
|
|
|
|
|
|
/* Waiting first 0xAA of header */
|
|
|
|
QCAFRM_WAIT_AA1 = QCAFRM_HW_LEN3 - 1,
|
|
|
|
|
|
|
|
/* Waiting second 0xAA of header */
|
|
|
|
QCAFRM_WAIT_AA2 = QCAFRM_WAIT_AA1 - 1,
|
|
|
|
|
|
|
|
/* Waiting third 0xAA of header */
|
|
|
|
QCAFRM_WAIT_AA3 = QCAFRM_WAIT_AA2 - 1,
|
|
|
|
|
|
|
|
/* Waiting fourth 0xAA of header */
|
|
|
|
QCAFRM_WAIT_AA4 = QCAFRM_WAIT_AA3 - 1,
|
|
|
|
|
|
|
|
/* Waiting Byte 0-1 of length (litte endian) */
|
|
|
|
QCAFRM_WAIT_LEN_BYTE0 = QCAFRM_WAIT_AA4 - 1,
|
|
|
|
QCAFRM_WAIT_LEN_BYTE1 = QCAFRM_WAIT_AA4 - 2,
|
|
|
|
|
|
|
|
/* Reserved bytes */
|
|
|
|
QCAFRM_WAIT_RSVD_BYTE1 = QCAFRM_WAIT_AA4 - 3,
|
|
|
|
QCAFRM_WAIT_RSVD_BYTE2 = QCAFRM_WAIT_AA4 - 4,
|
|
|
|
|
|
|
|
/* The frame length is used as the state until
|
|
|
|
* the end of the Ethernet frame
|
|
|
|
* Waiting for first 0x55 of footer
|
|
|
|
*/
|
|
|
|
QCAFRM_WAIT_551 = 1,
|
|
|
|
|
|
|
|
/* Waiting for second 0x55 of footer */
|
|
|
|
QCAFRM_WAIT_552 = QCAFRM_WAIT_551 - 1
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Structure to maintain the frame decoding during reception. */
|
|
|
|
|
|
|
|
struct qcafrm_handle {
|
|
|
|
/* Current decoding state */
|
|
|
|
enum qcafrm_state state;
|
2017-05-29 04:57:19 -07:00
|
|
|
/* Initial state depends on connection type */
|
|
|
|
enum qcafrm_state init;
|
2014-09-26 15:21:21 -07:00
|
|
|
|
|
|
|
/* Offset in buffer (borrowed for length too) */
|
2017-05-29 04:57:10 -07:00
|
|
|
u16 offset;
|
2014-09-26 15:21:21 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
u16 qcafrm_create_header(u8 *buf, u16 len);
|
|
|
|
|
|
|
|
u16 qcafrm_create_footer(u8 *buf);
|
|
|
|
|
2017-05-29 04:57:19 -07:00
|
|
|
static inline void qcafrm_fsm_init_spi(struct qcafrm_handle *handle)
|
2014-09-26 15:21:21 -07:00
|
|
|
{
|
2017-05-29 04:57:19 -07:00
|
|
|
handle->init = QCAFRM_HW_LEN0;
|
|
|
|
handle->state = handle->init;
|
2014-09-26 15:21:21 -07:00
|
|
|
}
|
|
|
|
|
2017-05-29 04:57:25 -07:00
|
|
|
static inline void qcafrm_fsm_init_uart(struct qcafrm_handle *handle)
|
|
|
|
{
|
|
|
|
handle->init = QCAFRM_WAIT_AA1;
|
|
|
|
handle->state = handle->init;
|
|
|
|
}
|
|
|
|
|
2014-09-26 15:21:21 -07:00
|
|
|
s32 qcafrm_fsm_decode(struct qcafrm_handle *handle, u8 *buf, u16 buf_len, u8 recv_byte);
|
|
|
|
|
|
|
|
#endif /* _QCA_FRAMING_H */
|