Skip to content

Commit 5637508

Browse files
Ravi Gunasekarankuba-moo
authored andcommitted
net: ti: icssg-prueth: Enable HSR Tx duplication, Tx Tag and Rx Tag offload
The HSR stack allows to offload its Tx packet duplication functionality to the hardware. Enable this offloading feature for ICSSG driver. Add support to offload HSR Tx Tag Insertion and Rx Tag Removal and duplicate discard. hsr tag insertion offload and hsr dup offload are tightly coupled in firmware implementation. Both these features need to be enabled / disabled together. Duplicate discard is done as part of RX tag removal and it is done by the firmware. When driver sends the r30 command ICSSG_EMAC_HSR_RX_OFFLOAD_ENABLE, firmware does RX tag removal as well as duplicate discard. Signed-off-by: Ravi Gunasekaran <[email protected]> Signed-off-by: MD Danish Anwar <[email protected]> Reviewed-by: Roger Quadros <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 95540ad commit 5637508

File tree

5 files changed

+58
-5
lines changed

5 files changed

+58
-5
lines changed

drivers/net/ethernet/ti/icssg/icssg_common.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -660,14 +660,15 @@ enum netdev_tx icssg_ndo_start_xmit(struct sk_buff *skb, struct net_device *ndev
660660
{
661661
struct cppi5_host_desc_t *first_desc, *next_desc, *cur_desc;
662662
struct prueth_emac *emac = netdev_priv(ndev);
663+
struct prueth *prueth = emac->prueth;
663664
struct netdev_queue *netif_txq;
664665
struct prueth_tx_chn *tx_chn;
665666
dma_addr_t desc_dma, buf_dma;
667+
u32 pkt_len, dst_tag_id;
666668
int i, ret = 0, q_idx;
667669
bool in_tx_ts = 0;
668670
int tx_ts_cookie;
669671
void **swdata;
670-
u32 pkt_len;
671672
u32 *epib;
672673

673674
pkt_len = skb_headlen(skb);
@@ -712,9 +713,20 @@ enum netdev_tx icssg_ndo_start_xmit(struct sk_buff *skb, struct net_device *ndev
712713

713714
/* set dst tag to indicate internal qid at the firmware which is at
714715
* bit8..bit15. bit0..bit7 indicates port num for directed
715-
* packets in case of switch mode operation
716+
* packets in case of switch mode operation and port num 0
717+
* for undirected packets in case of HSR offload mode
716718
*/
717-
cppi5_desc_set_tags_ids(&first_desc->hdr, 0, (emac->port_id | (q_idx << 8)));
719+
dst_tag_id = emac->port_id | (q_idx << 8);
720+
721+
if (prueth->is_hsr_offload_mode &&
722+
(ndev->features & NETIF_F_HW_HSR_DUP))
723+
dst_tag_id = PRUETH_UNDIRECTED_PKT_DST_TAG;
724+
725+
if (prueth->is_hsr_offload_mode &&
726+
(ndev->features & NETIF_F_HW_HSR_TAG_INS))
727+
epib[1] |= PRUETH_UNDIRECTED_PKT_TAG_INS;
728+
729+
cppi5_desc_set_tags_ids(&first_desc->hdr, 0, dst_tag_id);
718730
k3_udma_glue_tx_dma_to_cppi5_addr(tx_chn->tx_chn, &buf_dma);
719731
cppi5_hdesc_attach_buf(first_desc, buf_dma, pkt_len, buf_dma, pkt_len);
720732
swdata = cppi5_hdesc_get_swdata(first_desc);

drivers/net/ethernet/ti/icssg/icssg_config.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,9 @@ static const struct icssg_r30_cmd emac_r32_bitmask[] = {
531531
{{EMAC_NONE, 0xffff4000, EMAC_NONE, EMAC_NONE}}, /* Preemption on Tx ENABLE*/
532532
{{EMAC_NONE, 0xbfff0000, EMAC_NONE, EMAC_NONE}}, /* Preemption on Tx DISABLE*/
533533
{{0xffff0010, EMAC_NONE, 0xffff0010, EMAC_NONE}}, /* VLAN AWARE*/
534-
{{0xffef0000, EMAC_NONE, 0xffef0000, EMAC_NONE}} /* VLAN UNWARE*/
534+
{{0xffef0000, EMAC_NONE, 0xffef0000, EMAC_NONE}}, /* VLAN UNWARE*/
535+
{{0xffff2000, EMAC_NONE, EMAC_NONE, EMAC_NONE}}, /* HSR_RX_OFFLOAD_ENABLE */
536+
{{0xdfff0000, EMAC_NONE, EMAC_NONE, EMAC_NONE}} /* HSR_RX_OFFLOAD_DISABLE */
535537
};
536538

537539
int icssg_set_port_state(struct prueth_emac *emac,

drivers/net/ethernet/ti/icssg/icssg_config.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ enum icssg_port_state_cmd {
8080
ICSSG_EMAC_PORT_PREMPT_TX_DISABLE,
8181
ICSSG_EMAC_PORT_VLAN_AWARE_ENABLE,
8282
ICSSG_EMAC_PORT_VLAN_AWARE_DISABLE,
83+
ICSSG_EMAC_HSR_RX_OFFLOAD_ENABLE,
84+
ICSSG_EMAC_HSR_RX_OFFLOAD_DISABLE,
8385
ICSSG_EMAC_PORT_MAX_COMMANDS
8486
};
8587

drivers/net/ethernet/ti/icssg/icssg_prueth.c

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@
4141
#define DEFAULT_PORT_MASK 1
4242
#define DEFAULT_UNTAG_MASK 1
4343

44-
#define NETIF_PRUETH_HSR_OFFLOAD_FEATURES NETIF_F_HW_HSR_FWD
44+
#define NETIF_PRUETH_HSR_OFFLOAD_FEATURES (NETIF_F_HW_HSR_FWD | \
45+
NETIF_F_HW_HSR_DUP | \
46+
NETIF_F_HW_HSR_TAG_INS | \
47+
NETIF_F_HW_HSR_TAG_RM)
4548

4649
/* CTRLMMR_ICSSG_RGMII_CTRL register bits */
4750
#define ICSSG_CTRL_RGMII_ID_MODE BIT(24)
@@ -744,6 +747,29 @@ static void emac_ndo_set_rx_mode(struct net_device *ndev)
744747
queue_work(emac->cmd_wq, &emac->rx_mode_work);
745748
}
746749

750+
static netdev_features_t emac_ndo_fix_features(struct net_device *ndev,
751+
netdev_features_t features)
752+
{
753+
/* hsr tag insertion offload and hsr dup offload are tightly coupled in
754+
* firmware implementation. Both these features need to be enabled /
755+
* disabled together.
756+
*/
757+
if (!(ndev->features & (NETIF_F_HW_HSR_DUP | NETIF_F_HW_HSR_TAG_INS)))
758+
if ((features & NETIF_F_HW_HSR_DUP) ||
759+
(features & NETIF_F_HW_HSR_TAG_INS))
760+
features |= NETIF_F_HW_HSR_DUP |
761+
NETIF_F_HW_HSR_TAG_INS;
762+
763+
if ((ndev->features & NETIF_F_HW_HSR_DUP) ||
764+
(ndev->features & NETIF_F_HW_HSR_TAG_INS))
765+
if (!(features & NETIF_F_HW_HSR_DUP) ||
766+
!(features & NETIF_F_HW_HSR_TAG_INS))
767+
features &= ~(NETIF_F_HW_HSR_DUP |
768+
NETIF_F_HW_HSR_TAG_INS);
769+
770+
return features;
771+
}
772+
747773
static const struct net_device_ops emac_netdev_ops = {
748774
.ndo_open = emac_ndo_open,
749775
.ndo_stop = emac_ndo_stop,
@@ -755,6 +781,7 @@ static const struct net_device_ops emac_netdev_ops = {
755781
.ndo_eth_ioctl = icssg_ndo_ioctl,
756782
.ndo_get_stats64 = icssg_ndo_get_stats64,
757783
.ndo_get_phys_port_name = icssg_ndo_get_phys_port_name,
784+
.ndo_fix_features = emac_ndo_fix_features,
758785
};
759786

760787
static int prueth_netdev_init(struct prueth *prueth,
@@ -981,6 +1008,13 @@ static void icssg_change_mode(struct prueth *prueth)
9811008

9821009
for (mac = PRUETH_MAC0; mac < PRUETH_NUM_MACS; mac++) {
9831010
emac = prueth->emac[mac];
1011+
if (prueth->is_hsr_offload_mode) {
1012+
if (emac->ndev->features & NETIF_F_HW_HSR_TAG_RM)
1013+
icssg_set_port_state(emac, ICSSG_EMAC_HSR_RX_OFFLOAD_ENABLE);
1014+
else
1015+
icssg_set_port_state(emac, ICSSG_EMAC_HSR_RX_OFFLOAD_DISABLE);
1016+
}
1017+
9841018
if (netif_running(emac->ndev)) {
9851019
icssg_fdb_add_del(emac, eth_stp_addr, prueth->default_vlan,
9861020
ICSSG_FDB_ENTRY_P0_MEMBERSHIP |

drivers/net/ethernet/ti/icssg/icssg_prueth.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@
5959

6060
#define IEP_DEFAULT_CYCLE_TIME_NS 1000000 /* 1 ms */
6161

62+
#define PRUETH_UNDIRECTED_PKT_DST_TAG 0
63+
#define PRUETH_UNDIRECTED_PKT_TAG_INS BIT(30)
64+
6265
/* Firmware status codes */
6366
#define ICSS_HS_FW_READY 0x55555555
6467
#define ICSS_HS_FW_DEAD 0xDEAD0000 /* lower 16 bits contain error code */

0 commit comments

Comments
 (0)