Commit 74bd5dbe authored by Paolo Abeni's avatar Paolo Abeni

Merge branch 'support-icssg-based-ethernet-on-am65x-sr1-0-devices'

Diogo Ivo says:

====================
Support ICSSG-based Ethernet on AM65x SR1.0 devices

This series extends the current ICSSG-based Ethernet driver to support
AM65x Silicon Revision 1.0 devices.

Notable differences between the Silicon Revisions are that there is
no TX core in SR1.0 with this being handled by the firmware, requiring
extra DMA channels to manage communication with the firmware (with the
firmware being different as well) and in the packet classifier.

The motivation behind it is that a significant number of Siemens
devices containing SR1.0 silicon have been deployed in the field
and need to be supported and updated to newer kernel versions
without losing functionality.

This series is based on TI's 5.10 SDK [1].

The fifth version of this patch series can be found in [2].

Compared to the last version of the patch set there are only changes in
patch 05/10, where the fields of a struct are now explicitly declared as
__le32 so that we can properly interpret them.

Both of the problems mentioned in v4 have been addressed by disabling
those functionalities, meaning that this driver currently only supports
one TX queue and does not support a 100Mbit/s half-duplex connection.
The removal of these features has been commented in the appropriate
locations in the code.

[1]: https://git.ti.com/cgit/ti-linux-kernel/ti-linux-kernel/tree/?h=ti-linux-5.10.y
[2]: https://lore.kernel.org/netdev/20240326110709.26165-1-diogo.ivo@siemens.com/
====================

Link: https://lore.kernel.org/r/20240403104821.283832-1-diogo.ivo@siemens.comSigned-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parents 87c33315 e654b85a
...@@ -13,14 +13,12 @@ description: ...@@ -13,14 +13,12 @@ description:
Ethernet based on the Programmable Real-Time Unit and Industrial Ethernet based on the Programmable Real-Time Unit and Industrial
Communication Subsystem. Communication Subsystem.
allOf:
- $ref: /schemas/remoteproc/ti,pru-consumer.yaml#
properties: properties:
compatible: compatible:
enum: enum:
- ti,am642-icssg-prueth # for AM64x SoC family - ti,am642-icssg-prueth # for AM64x SoC family
- ti,am654-icssg-prueth # for AM65x SoC family - ti,am654-icssg-prueth # for AM65x SoC family
- ti,am654-sr1-icssg-prueth # for AM65x SoC family, SR1.0
sram: sram:
$ref: /schemas/types.yaml#/definitions/phandle $ref: /schemas/types.yaml#/definitions/phandle
...@@ -28,9 +26,11 @@ properties: ...@@ -28,9 +26,11 @@ properties:
phandle to MSMC SRAM node phandle to MSMC SRAM node
dmas: dmas:
maxItems: 10 minItems: 10
maxItems: 12
dma-names: dma-names:
minItems: 10
items: items:
- const: tx0-0 - const: tx0-0
- const: tx0-1 - const: tx0-1
...@@ -42,6 +42,8 @@ properties: ...@@ -42,6 +42,8 @@ properties:
- const: tx1-3 - const: tx1-3
- const: rx0 - const: rx0
- const: rx1 - const: rx1
- const: rxmgm0
- const: rxmgm1
ti,mii-g-rt: ti,mii-g-rt:
$ref: /schemas/types.yaml#/definitions/phandle $ref: /schemas/types.yaml#/definitions/phandle
...@@ -132,6 +134,27 @@ required: ...@@ -132,6 +134,27 @@ required:
- interrupts - interrupts
- interrupt-names - interrupt-names
allOf:
- $ref: /schemas/remoteproc/ti,pru-consumer.yaml#
- if:
properties:
compatible:
contains:
const: ti,am654-sr1-icssg-prueth
then:
properties:
dmas:
minItems: 12
dma-names:
minItems: 12
else:
properties:
dmas:
maxItems: 10
dma-names:
maxItems: 10
unevaluatedProperties: false unevaluatedProperties: false
examples: examples:
......
...@@ -198,6 +198,21 @@ config TI_ICSSG_PRUETH ...@@ -198,6 +198,21 @@ config TI_ICSSG_PRUETH
to support the Ethernet operation. Currently, it supports Ethernet to support the Ethernet operation. Currently, it supports Ethernet
with 1G and 100M link speed. with 1G and 100M link speed.
config TI_ICSSG_PRUETH_SR1
tristate "TI Gigabit PRU SR1.0 Ethernet driver"
select PHYLIB
select TI_ICSS_IEP
select TI_K3_CPPI_DESC_POOL
depends on PRU_REMOTEPROC
depends on ARCH_K3 && OF && TI_K3_UDMA_GLUE_LAYER
help
Support dual Gigabit Ethernet ports over the ICSSG PRU Subsystem.
This subsystem is available on the AM65 SR1.0 platform.
This driver requires firmware binaries which will run on the PRUs
to support the Ethernet operation. Currently, it supports Ethernet
with 1G, 100M and 10M link speed.
config TI_ICSS_IEP config TI_ICSS_IEP
tristate "TI PRU ICSS IEP driver" tristate "TI PRU ICSS IEP driver"
depends on PTP_1588_CLOCK_OPTIONAL depends on PTP_1588_CLOCK_OPTIONAL
......
...@@ -33,10 +33,19 @@ obj-$(CONFIG_TI_K3_AM65_CPTS) += am65-cpts.o ...@@ -33,10 +33,19 @@ obj-$(CONFIG_TI_K3_AM65_CPTS) += am65-cpts.o
obj-$(CONFIG_TI_ICSSG_PRUETH) += icssg-prueth.o obj-$(CONFIG_TI_ICSSG_PRUETH) += icssg-prueth.o
icssg-prueth-y := icssg/icssg_prueth.o \ icssg-prueth-y := icssg/icssg_prueth.o \
icssg/icssg_common.o \
icssg/icssg_classifier.o \ icssg/icssg_classifier.o \
icssg/icssg_queues.o \ icssg/icssg_queues.o \
icssg/icssg_config.o \ icssg/icssg_config.o \
icssg/icssg_mii_cfg.o \ icssg/icssg_mii_cfg.o \
icssg/icssg_stats.o \ icssg/icssg_stats.o \
icssg/icssg_ethtool.o icssg/icssg_ethtool.o
obj-$(CONFIG_TI_ICSSG_PRUETH_SR1) += icssg-prueth-sr1.o
icssg-prueth-sr1-y := icssg/icssg_prueth_sr1.o \
icssg/icssg_common.o \
icssg/icssg_classifier.o \
icssg/icssg_config.o \
icssg/icssg_mii_cfg.o \
icssg/icssg_stats.o \
icssg/icssg_ethtool.o
obj-$(CONFIG_TI_ICSS_IEP) += icssg/icss_iep.o obj-$(CONFIG_TI_ICSS_IEP) += icssg/icss_iep.o
...@@ -274,6 +274,16 @@ static void rx_class_set_or(struct regmap *miig_rt, int slice, int n, ...@@ -274,6 +274,16 @@ static void rx_class_set_or(struct regmap *miig_rt, int slice, int n,
regmap_write(miig_rt, offset, data); regmap_write(miig_rt, offset, data);
} }
static u32 rx_class_get_or(struct regmap *miig_rt, int slice, int n)
{
u32 offset, val;
offset = RX_CLASS_N_REG(slice, n, RX_CLASS_OR_EN);
regmap_read(miig_rt, offset, &val);
return val;
}
void icssg_class_set_host_mac_addr(struct regmap *miig_rt, const u8 *mac) void icssg_class_set_host_mac_addr(struct regmap *miig_rt, const u8 *mac)
{ {
regmap_write(miig_rt, MAC_INTERFACE_0, (u32)(mac[0] | mac[1] << 8 | regmap_write(miig_rt, MAC_INTERFACE_0, (u32)(mac[0] | mac[1] << 8 |
...@@ -288,6 +298,26 @@ void icssg_class_set_mac_addr(struct regmap *miig_rt, int slice, u8 *mac) ...@@ -288,6 +298,26 @@ void icssg_class_set_mac_addr(struct regmap *miig_rt, int slice, u8 *mac)
regmap_write(miig_rt, offs[slice].mac1, (u32)(mac[4] | mac[5] << 8)); regmap_write(miig_rt, offs[slice].mac1, (u32)(mac[4] | mac[5] << 8));
} }
static void icssg_class_ft1_add_mcast(struct regmap *miig_rt, int slice,
int slot, const u8 *addr, const u8 *mask)
{
u32 val;
int i;
WARN(slot >= FT1_NUM_SLOTS, "invalid slot: %d\n", slot);
rx_class_ft1_set_da(miig_rt, slice, slot, addr);
rx_class_ft1_set_da_mask(miig_rt, slice, slot, mask);
rx_class_ft1_cfg_set_type(miig_rt, slice, slot, FT1_CFG_TYPE_EQ);
/* Enable the FT1 slot in OR enable for all classifiers */
for (i = 0; i < ICSSG_NUM_CLASSIFIERS_IN_USE; i++) {
val = rx_class_get_or(miig_rt, slice, i);
val |= RX_CLASS_FT_FT1_MATCH(slot);
rx_class_set_or(miig_rt, slice, i, val);
}
}
/* disable all RX traffic */ /* disable all RX traffic */
void icssg_class_disable(struct regmap *miig_rt, int slice) void icssg_class_disable(struct regmap *miig_rt, int slice)
{ {
...@@ -331,14 +361,18 @@ void icssg_class_disable(struct regmap *miig_rt, int slice) ...@@ -331,14 +361,18 @@ void icssg_class_disable(struct regmap *miig_rt, int slice)
regmap_write(miig_rt, offs[slice].rx_class_cfg2, 0); regmap_write(miig_rt, offs[slice].rx_class_cfg2, 0);
} }
void icssg_class_default(struct regmap *miig_rt, int slice, bool allmulti) void icssg_class_default(struct regmap *miig_rt, int slice, bool allmulti,
bool is_sr1)
{ {
int num_classifiers = is_sr1 ? ICSSG_NUM_CLASSIFIERS_IN_USE : 1;
u32 data; u32 data;
int n;
/* defaults */ /* defaults */
icssg_class_disable(miig_rt, slice); icssg_class_disable(miig_rt, slice);
/* Setup Classifier */ /* Setup Classifier */
for (n = 0; n < num_classifiers; n++) {
/* match on Broadcast or MAC_PRU address */ /* match on Broadcast or MAC_PRU address */
data = RX_CLASS_FT_BC | RX_CLASS_FT_DA_P; data = RX_CLASS_FT_BC | RX_CLASS_FT_DA_P;
...@@ -346,15 +380,76 @@ void icssg_class_default(struct regmap *miig_rt, int slice, bool allmulti) ...@@ -346,15 +380,76 @@ void icssg_class_default(struct regmap *miig_rt, int slice, bool allmulti)
if (allmulti) if (allmulti)
data |= RX_CLASS_FT_MC; data |= RX_CLASS_FT_MC;
rx_class_set_or(miig_rt, slice, 0, data); rx_class_set_or(miig_rt, slice, n, data);
/* set CFG1 for OR_OR_AND for classifier */ /* set CFG1 for OR_OR_AND for classifier */
rx_class_sel_set_type(miig_rt, slice, 0, RX_CLASS_SEL_TYPE_OR_OR_AND); rx_class_sel_set_type(miig_rt, slice, n,
RX_CLASS_SEL_TYPE_OR_OR_AND);
}
/* clear CFG2 */ /* clear CFG2 */
regmap_write(miig_rt, offs[slice].rx_class_cfg2, 0); regmap_write(miig_rt, offs[slice].rx_class_cfg2, 0);
} }
void icssg_class_promiscuous_sr1(struct regmap *miig_rt, int slice)
{
u32 data, offset;
int n;
/* defaults */
icssg_class_disable(miig_rt, slice);
/* Setup Classifier */
for (n = 0; n < ICSSG_NUM_CLASSIFIERS_IN_USE; n++) {
/* set RAW_MASK to bypass filters */
offset = RX_CLASS_GATES_N_REG(slice, n);
regmap_read(miig_rt, offset, &data);
data |= RX_CLASS_GATES_RAW_MASK;
regmap_write(miig_rt, offset, data);
}
}
void icssg_class_add_mcast_sr1(struct regmap *miig_rt, int slice,
struct net_device *ndev)
{
u8 mask_addr[6] = { 0, 0, 0, 0, 0, 0xff };
struct netdev_hw_addr *ha;
int slot = 2;
rx_class_ft1_set_start_len(miig_rt, slice, 0, 6);
/* reserve first 2 slots for
* 1) 01-80-C2-00-00-XX Known Service Ethernet Multicast addresses
* 2) 01-00-5e-00-00-XX Local Network Control Block
* (224.0.0.0 - 224.0.0.255 (224.0.0/24))
*/
icssg_class_ft1_add_mcast(miig_rt, slice, 0,
eth_reserved_addr_base, mask_addr);
icssg_class_ft1_add_mcast(miig_rt, slice, 1,
eth_ipv4_mcast_addr_base, mask_addr);
mask_addr[5] = 0;
netdev_for_each_mc_addr(ha, ndev) {
/* skip addresses matching reserved slots */
if (!memcmp(eth_reserved_addr_base, ha->addr, 5) ||
!memcmp(eth_ipv4_mcast_addr_base, ha->addr, 5)) {
netdev_dbg(ndev, "mcast skip %pM\n", ha->addr);
continue;
}
if (slot >= FT1_NUM_SLOTS) {
netdev_dbg(ndev,
"can't add more than %d MC addresses, enabling allmulti\n",
FT1_NUM_SLOTS);
icssg_class_default(miig_rt, slice, 1, true);
break;
}
netdev_dbg(ndev, "mcast add %pM\n", ha->addr);
icssg_class_ft1_add_mcast(miig_rt, slice, slot,
ha->addr, mask_addr);
slot++;
}
}
/* required for SAV check */ /* required for SAV check */
void icssg_ft1_set_mac_addr(struct regmap *miig_rt, int slice, u8 *mac_addr) void icssg_ft1_set_mac_addr(struct regmap *miig_rt, int slice, u8 *mac_addr)
{ {
......
This diff is collapsed.
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
/* IPG is in core_clk cycles */ /* IPG is in core_clk cycles */
#define MII_RT_TX_IPG_100M 0x17 #define MII_RT_TX_IPG_100M 0x17
#define MII_RT_TX_IPG_1G 0xb #define MII_RT_TX_IPG_1G 0xb
#define MII_RT_TX_IPG_100M_SR1 0x166
#define MII_RT_TX_IPG_1G_SR1 0x1a
#define ICSSG_QUEUES_MAX 64 #define ICSSG_QUEUES_MAX 64
#define ICSSG_QUEUE_OFFSET 0xd00 #define ICSSG_QUEUE_OFFSET 0xd00
...@@ -202,23 +204,29 @@ void icssg_config_ipg(struct prueth_emac *emac) ...@@ -202,23 +204,29 @@ void icssg_config_ipg(struct prueth_emac *emac)
{ {
struct prueth *prueth = emac->prueth; struct prueth *prueth = emac->prueth;
int slice = prueth_emac_slice(emac); int slice = prueth_emac_slice(emac);
u32 ipg;
switch (emac->speed) { switch (emac->speed) {
case SPEED_1000: case SPEED_1000:
icssg_mii_update_ipg(prueth->mii_rt, slice, MII_RT_TX_IPG_1G); ipg = emac->is_sr1 ? MII_RT_TX_IPG_1G_SR1 : MII_RT_TX_IPG_1G;
break; break;
case SPEED_100: case SPEED_100:
icssg_mii_update_ipg(prueth->mii_rt, slice, MII_RT_TX_IPG_100M); ipg = emac->is_sr1 ? MII_RT_TX_IPG_100M_SR1 : MII_RT_TX_IPG_100M;
break; break;
case SPEED_10: case SPEED_10:
/* Firmware hardcodes IPG for SR1.0 */
if (emac->is_sr1)
return;
/* IPG for 10M is same as 100M */ /* IPG for 10M is same as 100M */
icssg_mii_update_ipg(prueth->mii_rt, slice, MII_RT_TX_IPG_100M); ipg = MII_RT_TX_IPG_100M;
break; break;
default: default:
/* Other links speeds not supported */ /* Other links speeds not supported */
netdev_err(emac->ndev, "Unsupported link speed\n"); netdev_err(emac->ndev, "Unsupported link speed\n");
return; return;
} }
icssg_mii_update_ipg(prueth->mii_rt, slice, ipg);
} }
static void emac_r30_cmd_init(struct prueth_emac *emac) static void emac_r30_cmd_init(struct prueth_emac *emac)
......
...@@ -109,6 +109,62 @@ enum icssg_port_state_cmd { ...@@ -109,6 +109,62 @@ enum icssg_port_state_cmd {
#define ICSSG_FLAG_MASK 0xff00ffff #define ICSSG_FLAG_MASK 0xff00ffff
/* SR1.0-specific bits */
#define PRUETH_MAX_RX_FLOWS_SR1 4 /* excluding default flow */
#define PRUETH_RX_FLOW_DATA_SR1 3 /* highest priority flow */
#define PRUETH_MAX_RX_MGM_DESC_SR1 8
#define PRUETH_MAX_RX_MGM_FLOWS_SR1 2 /* excluding default flow */
#define PRUETH_RX_MGM_FLOW_RESPONSE_SR1 0
#define PRUETH_RX_MGM_FLOW_TIMESTAMP_SR1 1
#define PRUETH_NUM_BUF_POOLS_SR1 16
#define PRUETH_EMAC_BUF_POOL_START_SR1 8
#define PRUETH_EMAC_BUF_POOL_MIN_SIZE_SR1 128
#define PRUETH_EMAC_BUF_SIZE_SR1 1536
#define PRUETH_EMAC_NUM_BUF_SR1 4
#define PRUETH_EMAC_BUF_POOL_SIZE_SR1 (PRUETH_EMAC_NUM_BUF_SR1 * \
PRUETH_EMAC_BUF_SIZE_SR1)
#define MSMC_RAM_SIZE_SR1 (SZ_64K + SZ_32K + SZ_2K) /* 0x1880 x 8 x 2 */
struct icssg_sr1_config {
__le32 status; /* Firmware status */
__le32 addr_lo; /* MSMC Buffer pool base address low. */
__le32 addr_hi; /* MSMC Buffer pool base address high. Must be 0 */
__le32 tx_buf_sz[16]; /* Array of buffer pool sizes */
__le32 num_tx_threads; /* Number of active egress threads, 1 to 4 */
__le32 tx_rate_lim_en; /* Bitmask: Egress rate limit en per thread */
__le32 rx_flow_id; /* RX flow id for first rx ring */
__le32 rx_mgr_flow_id; /* RX flow id for the first management ring */
__le32 flags; /* TBD */
__le32 n_burst; /* for debug */
__le32 rtu_status; /* RTU status */
__le32 info; /* reserved */
__le32 reserve;
__le32 rand_seed; /* Used for the random number generation at fw */
} __packed;
/* SR1.0 shutdown command to stop processing at firmware.
* Command format: 0x8101ss00, where
* - ss: sequence number. Currently not used by driver.
*/
#define ICSSG_SHUTDOWN_CMD_SR1 0x81010000
/* SR1.0 pstate speed/duplex command to set speed and duplex settings
* in firmware.
* Command format: 0x8102ssPN, where
* - ss: sequence number. Currently not used by driver.
* - P: port number (for switch mode).
* - N: Speed/Duplex state:
* 0x0 - 10Mbps/Half duplex;
* 0x8 - 10Mbps/Full duplex;
* 0x2 - 100Mbps/Half duplex;
* 0xa - 100Mbps/Full duplex;
* 0xc - 1Gbps/Full duplex;
* NOTE: The above are the same value as bits [3..1](slice 0)
* or bits [7..5](slice 1) of RGMII CFG register.
*/
#define ICSSG_PSTATE_SPEED_DUPLEX_CMD_SR1 0x81020000
struct icssg_setclock_desc { struct icssg_setclock_desc {
u8 request; u8 request;
u8 restore; u8 restore;
......
...@@ -142,6 +142,9 @@ static int emac_set_channels(struct net_device *ndev, ...@@ -142,6 +142,9 @@ static int emac_set_channels(struct net_device *ndev,
emac->tx_ch_num = ch->tx_count; emac->tx_ch_num = ch->tx_count;
if (emac->is_sr1)
emac->tx_ch_num++;
return 0; return 0;
} }
...@@ -152,8 +155,17 @@ static void emac_get_channels(struct net_device *ndev, ...@@ -152,8 +155,17 @@ static void emac_get_channels(struct net_device *ndev,
ch->max_rx = 1; ch->max_rx = 1;
ch->max_tx = PRUETH_MAX_TX_QUEUES; ch->max_tx = PRUETH_MAX_TX_QUEUES;
/* Disable multiple TX channels due to timeouts
* when using more than one queue */
if (emac->is_sr1)
ch->max_tx = 1;
ch->rx_count = 1; ch->rx_count = 1;
ch->tx_count = emac->tx_ch_num; ch->tx_count = emac->tx_ch_num;
if (emac->is_sr1)
ch->tx_count--;
} }
static const struct ethtool_rmon_hist_range emac_rmon_ranges[] = { static const struct ethtool_rmon_hist_range emac_rmon_ranges[] = {
......
...@@ -55,6 +55,8 @@ ...@@ -55,6 +55,8 @@
#define ICSSG_NUM_STANDARD_STATS 31 #define ICSSG_NUM_STANDARD_STATS 31
#define ICSSG_NUM_ETHTOOL_STATS (ICSSG_NUM_STATS - ICSSG_NUM_STANDARD_STATS) #define ICSSG_NUM_ETHTOOL_STATS (ICSSG_NUM_STATS - ICSSG_NUM_STANDARD_STATS)
#define IEP_DEFAULT_CYCLE_TIME_NS 1000000 /* 1 ms */
/* Firmware status codes */ /* Firmware status codes */
#define ICSS_HS_FW_READY 0x55555555 #define ICSS_HS_FW_READY 0x55555555
#define ICSS_HS_FW_DEAD 0xDEAD0000 /* lower 16 bits contain error code */ #define ICSS_HS_FW_DEAD 0xDEAD0000 /* lower 16 bits contain error code */
...@@ -127,6 +129,7 @@ struct prueth_rx_chn { ...@@ -127,6 +129,7 @@ struct prueth_rx_chn {
/* data for each emac port */ /* data for each emac port */
struct prueth_emac { struct prueth_emac {
bool is_sr1;
bool fw_running; bool fw_running;
struct prueth *prueth; struct prueth *prueth;
struct net_device *ndev; struct net_device *ndev;
...@@ -155,6 +158,10 @@ struct prueth_emac { ...@@ -155,6 +158,10 @@ struct prueth_emac {
int rx_flow_id_base; int rx_flow_id_base;
int tx_ch_num; int tx_ch_num;
/* SR1.0 Management channel */
struct prueth_rx_chn rx_mgm_chn;
int rx_mgm_flow_id_base;
spinlock_t lock; /* serialize access */ spinlock_t lock; /* serialize access */
/* TX HW Timestamping */ /* TX HW Timestamping */
...@@ -165,7 +172,7 @@ struct prueth_emac { ...@@ -165,7 +172,7 @@ struct prueth_emac {
u8 cmd_seq; u8 cmd_seq;
/* shutdown related */ /* shutdown related */
u32 cmd_data[4]; __le32 cmd_data[4];
struct completion cmd_complete; struct completion cmd_complete;
/* Mutex to serialize access to firmware command interface */ /* Mutex to serialize access to firmware command interface */
struct mutex cmd_lock; struct mutex cmd_lock;
...@@ -188,6 +195,12 @@ struct prueth_pdata { ...@@ -188,6 +195,12 @@ struct prueth_pdata {
u32 quirk_10m_link_issue:1; u32 quirk_10m_link_issue:1;
}; };
struct icssg_firmwares {
char *pru;
char *rtu;
char *txpru;
};
/** /**
* struct prueth - PRUeth structure * struct prueth - PRUeth structure
* @dev: device * @dev: device
...@@ -243,6 +256,13 @@ struct emac_tx_ts_response { ...@@ -243,6 +256,13 @@ struct emac_tx_ts_response {
u32 hi_ts; u32 hi_ts;
}; };
struct emac_tx_ts_response_sr1 {
__le32 lo_ts;
__le32 hi_ts;
__le32 reserved;
__le32 cookie;
};
/* get PRUSS SLICE number from prueth_emac */ /* get PRUSS SLICE number from prueth_emac */
static inline int prueth_emac_slice(struct prueth_emac *emac) static inline int prueth_emac_slice(struct prueth_emac *emac)
{ {
...@@ -257,12 +277,17 @@ static inline int prueth_emac_slice(struct prueth_emac *emac) ...@@ -257,12 +277,17 @@ static inline int prueth_emac_slice(struct prueth_emac *emac)
} }
extern const struct ethtool_ops icssg_ethtool_ops; extern const struct ethtool_ops icssg_ethtool_ops;
extern const struct dev_pm_ops prueth_dev_pm_ops;
/* Classifier helpers */ /* Classifier helpers */
void icssg_class_set_mac_addr(struct regmap *miig_rt, int slice, u8 *mac); void icssg_class_set_mac_addr(struct regmap *miig_rt, int slice, u8 *mac);
void icssg_class_set_host_mac_addr(struct regmap *miig_rt, const u8 *mac); void icssg_class_set_host_mac_addr(struct regmap *miig_rt, const u8 *mac);
void icssg_class_disable(struct regmap *miig_rt, int slice); void icssg_class_disable(struct regmap *miig_rt, int slice);
void icssg_class_default(struct regmap *miig_rt, int slice, bool allmulti); void icssg_class_default(struct regmap *miig_rt, int slice, bool allmulti,
bool is_sr1);
void icssg_class_promiscuous_sr1(struct regmap *miig_rt, int slice);
void icssg_class_add_mcast_sr1(struct regmap *miig_rt, int slice,
struct net_device *ndev);
void icssg_ft1_set_mac_addr(struct regmap *miig_rt, int slice, u8 *mac_addr); void icssg_ft1_set_mac_addr(struct regmap *miig_rt, int slice, u8 *mac_addr);
/* config helpers */ /* config helpers */
...@@ -285,4 +310,54 @@ u32 icssg_queue_level(struct prueth *prueth, int queue); ...@@ -285,4 +310,54 @@ u32 icssg_queue_level(struct prueth *prueth, int queue);
void emac_stats_work_handler(struct work_struct *work); void emac_stats_work_handler(struct work_struct *work);
void emac_update_hardware_stats(struct prueth_emac *emac); void emac_update_hardware_stats(struct prueth_emac *emac);
int emac_get_stat_by_name(struct prueth_emac *emac, char *stat_name); int emac_get_stat_by_name(struct prueth_emac *emac, char *stat_name);
/* Common functions */
void prueth_cleanup_rx_chns(struct prueth_emac *emac,
struct prueth_rx_chn *rx_chn,
int max_rflows);
void prueth_cleanup_tx_chns(struct prueth_emac *emac);
void prueth_ndev_del_tx_napi(struct prueth_emac *emac, int num);
void prueth_xmit_free(struct prueth_tx_chn *tx_chn,
struct cppi5_host_desc_t *desc);
int emac_tx_complete_packets(struct prueth_emac *emac, int chn,
int budget);
int prueth_ndev_add_tx_napi(struct prueth_emac *emac);
int prueth_init_tx_chns(struct prueth_emac *emac);
int prueth_init_rx_chns(struct prueth_emac *emac,
struct prueth_rx_chn *rx_chn,
char *name, u32 max_rflows,
u32 max_desc_num);
int prueth_dma_rx_push(struct prueth_emac *emac,
struct sk_buff *skb,
struct prueth_rx_chn *rx_chn);
void emac_rx_timestamp(struct prueth_emac *emac,
struct sk_buff *skb, u32 *psdata);
enum netdev_tx emac_ndo_start_xmit(struct sk_buff *skb, struct net_device *ndev);
irqreturn_t prueth_rx_irq(int irq, void *dev_id);
void prueth_emac_stop(struct prueth_emac *emac);
void prueth_cleanup_tx_ts(struct prueth_emac *emac);
int emac_napi_rx_poll(struct napi_struct *napi_rx, int budget);
int prueth_prepare_rx_chan(struct prueth_emac *emac,
struct prueth_rx_chn *chn,
int buf_size);
void prueth_reset_tx_chan(struct prueth_emac *emac, int ch_num,
bool free_skb);
void prueth_reset_rx_chan(struct prueth_rx_chn *chn,
int num_flows, bool disable);
void emac_ndo_tx_timeout(struct net_device *ndev, unsigned int txqueue);
int emac_ndo_ioctl(struct net_device *ndev, struct ifreq *ifr, int cmd);
void emac_ndo_get_stats64(struct net_device *ndev,
struct rtnl_link_stats64 *stats);
int emac_ndo_get_phys_port_name(struct net_device *ndev, char *name,
size_t len);
int prueth_node_port(struct device_node *eth_node);
int prueth_node_mac(struct device_node *eth_node);
void prueth_netdev_exit(struct prueth *prueth,
struct device_node *eth_node);
int prueth_get_cores(struct prueth *prueth, int slice, bool is_sr1);
void prueth_put_cores(struct prueth *prueth, int slice);
/* Revision specific helper */
u64 icssg_ts_to_ns(u32 hi_sw, u32 hi, u32 lo, u32 cycle_time_ns);
#endif /* __NET_TI_ICSSG_PRUETH_H */ #endif /* __NET_TI_ICSSG_PRUETH_H */
This diff is collapsed.
...@@ -71,6 +71,12 @@ static const u8 eth_reserved_addr_base[ETH_ALEN] __aligned(2) = ...@@ -71,6 +71,12 @@ static const u8 eth_reserved_addr_base[ETH_ALEN] __aligned(2) =
{ 0x01, 0x80, 0xc2, 0x00, 0x00, 0x00 }; { 0x01, 0x80, 0xc2, 0x00, 0x00, 0x00 };
#define eth_stp_addr eth_reserved_addr_base #define eth_stp_addr eth_reserved_addr_base
static const u8 eth_ipv4_mcast_addr_base[ETH_ALEN] __aligned(2) =
{ 0x01, 0x00, 0x5e, 0x00, 0x00, 0x00 };
static const u8 eth_ipv6_mcast_addr_base[ETH_ALEN] __aligned(2) =
{ 0x33, 0x33, 0x00, 0x00, 0x00, 0x00 };
/** /**
* is_link_local_ether_addr - Determine if given Ethernet address is link-local * is_link_local_ether_addr - Determine if given Ethernet address is link-local
* @addr: Pointer to a six-byte array containing the Ethernet address * @addr: Pointer to a six-byte array containing the Ethernet address
...@@ -430,18 +436,16 @@ static inline bool ether_addr_equal_masked(const u8 *addr1, const u8 *addr2, ...@@ -430,18 +436,16 @@ static inline bool ether_addr_equal_masked(const u8 *addr1, const u8 *addr2,
static inline bool ether_addr_is_ipv4_mcast(const u8 *addr) static inline bool ether_addr_is_ipv4_mcast(const u8 *addr)
{ {
u8 base[ETH_ALEN] = { 0x01, 0x00, 0x5e, 0x00, 0x00, 0x00 };
u8 mask[ETH_ALEN] = { 0xff, 0xff, 0xff, 0x80, 0x00, 0x00 }; u8 mask[ETH_ALEN] = { 0xff, 0xff, 0xff, 0x80, 0x00, 0x00 };
return ether_addr_equal_masked(addr, base, mask); return ether_addr_equal_masked(addr, eth_ipv4_mcast_addr_base, mask);
} }
static inline bool ether_addr_is_ipv6_mcast(const u8 *addr) static inline bool ether_addr_is_ipv6_mcast(const u8 *addr)
{ {
u8 base[ETH_ALEN] = { 0x33, 0x33, 0x00, 0x00, 0x00, 0x00 };
u8 mask[ETH_ALEN] = { 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 }; u8 mask[ETH_ALEN] = { 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 };
return ether_addr_equal_masked(addr, base, mask); return ether_addr_equal_masked(addr, eth_ipv6_mcast_addr_base, mask);
} }
static inline bool ether_addr_is_ip_mcast(const u8 *addr) static inline bool ether_addr_is_ip_mcast(const u8 *addr)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment