Skip to content

Commit f0a1913

Browse files
Subbaraya Sundeepkuba-moo
authored andcommitted
octeontx2-pf: Add support for ethtool ntuple filters
This patch adds support for adding and deleting ethtool ntuple filters. The filters for ether, ipv4, ipv6, tcp, udp and sctp are supported. The mask is also supported. The supported actions are drop and direct to a queue. Additionally we support FLOW_EXT field vlan_tci and FLOW_MAC_EXT. The NIX PF will allocate total 32 MCAM entries for the use of ethtool ntuple filters. The Administrative Function(AF) will install/delete the MCAM rules when NIX PF sends mailbox message to install/delete the ntuple filters. Ethtool ntuple filters support is restricted to PFs as of now and PF can install ntuple filters to direct the traffic to its VFs. Hence added a separate callback for VFs to get/set RSS configuration. Signed-off-by: Subbaraya Sundeep <[email protected]> Signed-off-by: Sunil Goutham <[email protected]> Signed-off-by: Naveen Mamindlapalli <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 55307fc commit f0a1913

File tree

5 files changed

+707
-5
lines changed

5 files changed

+707
-5
lines changed

drivers/net/ethernet/marvell/octeontx2/nic/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ obj-$(CONFIG_OCTEONTX2_PF) += octeontx2_nicpf.o
77
obj-$(CONFIG_OCTEONTX2_VF) += octeontx2_nicvf.o
88

99
octeontx2_nicpf-y := otx2_pf.o otx2_common.o otx2_txrx.o otx2_ethtool.o \
10-
otx2_ptp.o
10+
otx2_ptp.o otx2_flows.o
1111
octeontx2_nicvf-y := otx2_vf.o
1212

1313
ccflags-y += -I$(srctree)/drivers/net/ethernet/marvell/octeontx2/af

drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <linux/timecounter.h>
1919

2020
#include <mbox.h>
21+
#include <npc.h>
2122
#include "otx2_reg.h"
2223
#include "otx2_txrx.h"
2324
#include <rvu_trace.h>
@@ -228,6 +229,16 @@ struct otx2_ptp {
228229

229230
#define OTX2_HW_TIMESTAMP_LEN 8
230231

232+
struct otx2_flow_config {
233+
u16 entry[NPC_MAX_NONCONTIG_ENTRIES];
234+
u32 nr_flows;
235+
#define OTX2_MAX_NTUPLE_FLOWS 32
236+
#define OTX2_MCAM_COUNT OTX2_MAX_NTUPLE_FLOWS
237+
u32 ntuple_offset;
238+
u32 ntuple_max_flows;
239+
struct list_head flow_list;
240+
};
241+
231242
struct otx2_nic {
232243
void __iomem *reg_base;
233244
struct net_device *netdev;
@@ -238,6 +249,8 @@ struct otx2_nic {
238249
#define OTX2_FLAG_RX_TSTAMP_ENABLED BIT_ULL(0)
239250
#define OTX2_FLAG_TX_TSTAMP_ENABLED BIT_ULL(1)
240251
#define OTX2_FLAG_INTF_DOWN BIT_ULL(2)
252+
#define OTX2_FLAG_MCAM_ENTRIES_ALLOC BIT_ULL(3)
253+
#define OTX2_FLAG_NTUPLE_SUPPORT BIT_ULL(4)
241254
#define OTX2_FLAG_RX_PAUSE_ENABLED BIT_ULL(9)
242255
#define OTX2_FLAG_TX_PAUSE_ENABLED BIT_ULL(10)
243256
u64 flags;
@@ -275,6 +288,8 @@ struct otx2_nic {
275288

276289
struct otx2_ptp *ptp;
277290
struct hwtstamp_config tstamp;
291+
292+
struct otx2_flow_config *flow_cfg;
278293
};
279294

280295
static inline bool is_otx2_lbkvf(struct pci_dev *pdev)
@@ -644,4 +659,20 @@ int otx2_open(struct net_device *netdev);
644659
int otx2_stop(struct net_device *netdev);
645660
int otx2_set_real_num_queues(struct net_device *netdev,
646661
int tx_queues, int rx_queues);
662+
/* MCAM filter related APIs */
663+
int otx2_mcam_flow_init(struct otx2_nic *pf);
664+
int otx2_alloc_mcam_entries(struct otx2_nic *pfvf);
665+
void otx2_mcam_flow_del(struct otx2_nic *pf);
666+
int otx2_destroy_ntuple_flows(struct otx2_nic *pf);
667+
int otx2_destroy_mcam_flows(struct otx2_nic *pfvf);
668+
int otx2_get_flow(struct otx2_nic *pfvf,
669+
struct ethtool_rxnfc *nfc, u32 location);
670+
int otx2_get_all_flows(struct otx2_nic *pfvf,
671+
struct ethtool_rxnfc *nfc, u32 *rule_locs);
672+
int otx2_add_flow(struct otx2_nic *pfvf,
673+
struct ethtool_rx_flow_spec *fsp);
674+
int otx2_remove_flow(struct otx2_nic *pfvf, u32 location);
675+
int otx2_prepare_flow_request(struct ethtool_rx_flow_spec *fsp,
676+
struct npc_install_flow_req *req);
677+
647678
#endif /* OTX2_COMMON_H */

drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,16 @@ static int otx2_get_rxnfc(struct net_device *dev,
551551
nfc->data = pfvf->hw.rx_queues;
552552
ret = 0;
553553
break;
554+
case ETHTOOL_GRXCLSRLCNT:
555+
nfc->rule_cnt = pfvf->flow_cfg->nr_flows;
556+
ret = 0;
557+
break;
558+
case ETHTOOL_GRXCLSRULE:
559+
ret = otx2_get_flow(pfvf, nfc, nfc->fs.location);
560+
break;
561+
case ETHTOOL_GRXCLSRLALL:
562+
ret = otx2_get_all_flows(pfvf, nfc, rules);
563+
break;
554564
case ETHTOOL_GRXFH:
555565
return otx2_get_rss_hash_opts(pfvf, nfc);
556566
default:
@@ -560,6 +570,50 @@ static int otx2_get_rxnfc(struct net_device *dev,
560570
}
561571

562572
static int otx2_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *nfc)
573+
{
574+
bool ntuple = !!(dev->features & NETIF_F_NTUPLE);
575+
struct otx2_nic *pfvf = netdev_priv(dev);
576+
int ret = -EOPNOTSUPP;
577+
578+
switch (nfc->cmd) {
579+
case ETHTOOL_SRXFH:
580+
ret = otx2_set_rss_hash_opts(pfvf, nfc);
581+
break;
582+
case ETHTOOL_SRXCLSRLINS:
583+
if (netif_running(dev) && ntuple)
584+
ret = otx2_add_flow(pfvf, &nfc->fs);
585+
break;
586+
case ETHTOOL_SRXCLSRLDEL:
587+
if (netif_running(dev) && ntuple)
588+
ret = otx2_remove_flow(pfvf, nfc->fs.location);
589+
break;
590+
default:
591+
break;
592+
}
593+
594+
return ret;
595+
}
596+
597+
static int otx2vf_get_rxnfc(struct net_device *dev,
598+
struct ethtool_rxnfc *nfc, u32 *rules)
599+
{
600+
struct otx2_nic *pfvf = netdev_priv(dev);
601+
int ret = -EOPNOTSUPP;
602+
603+
switch (nfc->cmd) {
604+
case ETHTOOL_GRXRINGS:
605+
nfc->data = pfvf->hw.rx_queues;
606+
ret = 0;
607+
break;
608+
case ETHTOOL_GRXFH:
609+
return otx2_get_rss_hash_opts(pfvf, nfc);
610+
default:
611+
break;
612+
}
613+
return ret;
614+
}
615+
616+
static int otx2vf_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *nfc)
563617
{
564618
struct otx2_nic *pfvf = netdev_priv(dev);
565619
int ret = -EOPNOTSUPP;
@@ -806,8 +860,8 @@ static const struct ethtool_ops otx2vf_ethtool_ops = {
806860
.get_sset_count = otx2vf_get_sset_count,
807861
.set_channels = otx2_set_channels,
808862
.get_channels = otx2_get_channels,
809-
.get_rxnfc = otx2_get_rxnfc,
810-
.set_rxnfc = otx2_set_rxnfc,
863+
.get_rxnfc = otx2vf_get_rxnfc,
864+
.set_rxnfc = otx2vf_set_rxnfc,
811865
.get_rxfh_key_size = otx2_get_rxfh_key_size,
812866
.get_rxfh_indir_size = otx2_get_rxfh_indir_size,
813867
.get_rxfh = otx2_get_rxfh,

0 commit comments

Comments
 (0)