summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRavi Gunasekaran <r-gunasekaran@ti.com>2024-03-12 15:56:57 +0530
committerPraneeth Bajjuri <praneeth@ti.com>2024-03-12 15:51:03 -0500
commitc6abd1410cce11168822ad71f9c344108aa3c6d0 (patch)
tree38f9ff2f485036f4a0392effd4dad3b69d2bd495
parent4670156ee7073e890934851fb43d429bb868892c (diff)
net: ethernet: ti: icssg_prueth: Enable HSR Tx Tag and Rx Tag offload
Add support to offload HSR Tx Tag Insertion and Rx Tag Removal and duplicate discard. Support for offloading these features needs ICSSG HSR FW version REL.HSR_1G_01.02.00.01. Steps to offload to HSR Tx Tag Insertion and Rx Tag Removal. ----------------------------------------------------------- Example assuming eth1, eth2 ports of ICSSG1 on AM64-EVM 1) Delete existing HSR interface ip link delete hsr0 2) Bring down the interfaces ip link set eth1 down ip link set eth2 down 3) Configure both interfaces to have same MAC address ip link set dev eth2 address <ETH1_MAC_ADDRESS> 4) Enable HSR offload for both interfaces ethtool -K eth1 hsr-fwd-offload on ethtool -K eth1 hsr-dup-offload on ethtool -K eth1 hsr-tag-ins-offload on ethtool -K eth1 hsr-tag-rm-offload on ethtool -K eth2 hsr-fwd-offload on ethtool -K eth2 hsr-dup-offload on ethtool -K eth2 hsr-tag-ins-offload on ethtool -K eth2 hsr-tag-rm-offload on devlink dev param set platform/icssg1-eth \ name hsr_offload_mode \ value true cmode runtime 5) Bring up the interfaces ip link set eth1 up ip link set eth2 up 6) Create HSR interface and add slave interfaces to it ip link add name hsr0 type hsr slave1 eth1 slave2 eth2 \ supervision 45 version 1 7) Add IP address to the HSR interface ip addr add <IP_ADDR>/24 dev hsr0 8) Bring up the HSR interface ip link set hsr0 up Switching back to Dual EMAC mode: --------------------------------- 1) Delete HSR interface ip link delete hsr0 2) Bring down the interfaces ip link set eth1 down ip link set eth2 down 3) Disable HSR port-to-port offloading mode, packet duplication ethtool -K eth1 hsr-fwd-offload off ethtool -K eth1 hsr-dup-offload off ethtool -K eth1 hsr-tag-ins-offload off ethtool -K eth1 hsr-tag-rm-offload off ethtool -K eth2 hsr-fwd-offload off ethtool -K eth2 hsr-dup-offload off ethtool -K eth2 hsr-tag-ins-offload off ethtool -K eth2 hsr-tag-rm-offload off devlink dev param set platform/icssg1-eth \ name hsr_offload_mode \ value false cmode runtime Note: 1) At the very least, hsr-fwd-offload must be enabled. Without offloading the port-to-port offload, other HSR offloads cannot be enabled. 2) Inorder to enable hsr-tag-ins-offload, hsr-dup-offload must also be enabled as these are tightly coupled in the firmware implementation. Signed-off-by: Ravi Gunasekaran <r-gunasekaran@ti.com>
-rw-r--r--drivers/net/ethernet/ti/icssg_config.c4
-rw-r--r--drivers/net/ethernet/ti/icssg_config.h2
-rw-r--r--drivers/net/ethernet/ti/icssg_prueth.c15
3 files changed, 19 insertions, 2 deletions
diff --git a/drivers/net/ethernet/ti/icssg_config.c b/drivers/net/ethernet/ti/icssg_config.c
index aea2ae8a3ae9..9d34ec0cb682 100644
--- a/drivers/net/ethernet/ti/icssg_config.c
+++ b/drivers/net/ethernet/ti/icssg_config.c
@@ -551,7 +551,9 @@ static const struct icssg_r30_cmd emac_r32_bitmask[] = {
{{EMAC_NONE, 0xffff4000, EMAC_NONE, EMAC_NONE}}, /* Preemption on Tx ENABLE*/
{{EMAC_NONE, 0xbfff0000, EMAC_NONE, EMAC_NONE}}, /* Preemption on Tx DISABLE*/
{{0xffff0010, EMAC_NONE, 0xffff0010, EMAC_NONE}}, /* VLAN AWARE*/
- {{0xffef0000, EMAC_NONE, 0xffef0000, EMAC_NONE}} /* VLAN UNWARE*/
+ {{0xffef0000, EMAC_NONE, 0xffef0000, EMAC_NONE}}, /* VLAN UNWARE*/
+ {{0xffff2000, EMAC_NONE, EMAC_NONE, EMAC_NONE}}, /* HSR_RX_OFFLOAD_ENABLE */
+ {{0xdfff0000, EMAC_NONE, EMAC_NONE, EMAC_NONE}} /* HSR_RX_OFFLOAD_DISABLE */
};
int emac_set_port_state(struct prueth_emac *emac,
diff --git a/drivers/net/ethernet/ti/icssg_config.h b/drivers/net/ethernet/ti/icssg_config.h
index ff61c66cec60..1f318884fa1b 100644
--- a/drivers/net/ethernet/ti/icssg_config.h
+++ b/drivers/net/ethernet/ti/icssg_config.h
@@ -81,6 +81,8 @@ enum icssg_port_state_cmd {
ICSSG_EMAC_PORT_PREMPT_TX_DISABLE,
ICSSG_EMAC_PORT_VLAN_AWARE_ENABLE,
ICSSG_EMAC_PORT_VLAN_AWARE_DISABLE,
+ ICSSG_EMAC_HSR_RX_OFFLOAD_ENABLE,
+ ICSSG_EMAC_HSR_RX_OFFLOAD_DISABLE,
ICSSG_EMAC_PORT_MAX_COMMANDS
};
diff --git a/drivers/net/ethernet/ti/icssg_prueth.c b/drivers/net/ethernet/ti/icssg_prueth.c
index 613b78775580..b6b075bf64d0 100644
--- a/drivers/net/ethernet/ti/icssg_prueth.c
+++ b/drivers/net/ethernet/ti/icssg_prueth.c
@@ -67,7 +67,9 @@
#define DEFAULT_UNTAG_MASK 1
#define NETIF_PRUETH_HSR_OFFLOAD (NETIF_F_HW_HSR_FWD | \
- NETIF_F_HW_HSR_DUP)
+ NETIF_F_HW_HSR_DUP | \
+ NETIF_F_HW_HSR_TAG_INS | \
+ NETIF_F_HW_HSR_TAG_RM)
/* CTRLMMR_ICSSG_RGMII_CTRL register bits */
#define ICSSG_CTRL_RGMII_ID_MODE BIT(24)
@@ -75,6 +77,7 @@
#define IEP_DEFAULT_CYCLE_TIME_NS 1000000 /* 1 ms */
#define PRUETH_UNDIRECTED_PKT_DST_TAG 0
+#define PRUETH_UNDIRECTED_PKT_TAG_INS BIT(30)
static void prueth_cleanup_rx_chns(struct prueth_emac *emac,
struct prueth_rx_chn *rx_chn,
@@ -875,6 +878,9 @@ static enum netdev_tx emac_ndo_start_xmit(struct sk_buff *skb, struct net_device
if (prueth->is_hsr_offload_mode && (ndev->features & NETIF_F_HW_HSR_DUP))
dst_tag_id = PRUETH_UNDIRECTED_PKT_DST_TAG;
+ if (prueth->is_hsr_offload_mode && (ndev->features & NETIF_F_HW_HSR_TAG_INS))
+ epib[1] |= PRUETH_UNDIRECTED_PKT_TAG_INS;
+
cppi5_desc_set_tags_ids(&first_desc->hdr, 0, dst_tag_id);
k3_udma_glue_tx_dma_to_cppi5_addr(tx_chn->tx_chn, &buf_dma);
cppi5_hdesc_attach_buf(first_desc, buf_dma, pkt_len, buf_dma, pkt_len);
@@ -1678,6 +1684,13 @@ static int emac_ndo_open(struct net_device *ndev)
}
}
+ if (prueth->is_hsr_offload_mode) {
+ if (ndev->features & NETIF_F_HW_HSR_TAG_RM)
+ emac_set_port_state(emac, ICSSG_EMAC_HSR_RX_OFFLOAD_ENABLE);
+ else
+ emac_set_port_state(emac, ICSSG_EMAC_HSR_RX_OFFLOAD_DISABLE);
+ }
+
flow_cfg = emac->dram.va + ICSSG_CONFIG_OFFSET + PSI_L_REGULAR_FLOW_ID_BASE_OFFSET;
writew(emac->rx_flow_id_base, &flow_cfg->rx_base_flow);
ret = emac_fdb_flow_id_updated(emac);