Skip to content

Commit 2ae7408

Browse files
Sathya Perladavem330
authored andcommitted
bnxt_en: bnxt: add TC flower filter offload support
This patch adds support for offloading TC based flow rules and actions for the 'flower' classifier in the bnxt_en driver. It includes logic to parse flow rules and actions received from the TC subsystem, store them and issue the corresponding hwrm_cfa_flow_alloc/free FW cmds. L2/IPv4/IPv6 flows and drop, redir, vlan push/pop actions are supported in this patch. In this patch the hwrm_cfa_flow_xxx routines are just stubs. The code for these routines is introduced in the next patch for easier review. Also, the code to query the TC/flower action stats will be introduced in a subsequent patch. Signed-off-by: Sathya Perla <[email protected]> Signed-off-by: Michael Chan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 7085560 commit 2ae7408

File tree

8 files changed

+850
-9
lines changed

8 files changed

+850
-9
lines changed

drivers/net/ethernet/broadcom/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,15 @@ config BNXT_SRIOV
212212
Virtualization support in the NetXtreme-C/E products. This
213213
allows for virtual function acceleration in virtual environments.
214214

215+
config BNXT_FLOWER_OFFLOAD
216+
bool "TC Flower offload support for NetXtreme-C/E"
217+
depends on BNXT
218+
default y
219+
---help---
220+
This configuration parameter enables TC Flower packet classifier
221+
offload for eswitch. This option enables SR-IOV switchdev eswitch
222+
offload.
223+
215224
config BNXT_DCB
216225
bool "Data Center Bridging (DCB) Support"
217226
default n
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
obj-$(CONFIG_BNXT) += bnxt_en.o
22

3-
bnxt_en-y := bnxt.o bnxt_sriov.o bnxt_ethtool.o bnxt_dcb.o bnxt_ulp.o bnxt_xdp.o bnxt_vfr.o
3+
bnxt_en-y := bnxt.o bnxt_sriov.o bnxt_ethtool.o bnxt_dcb.o bnxt_ulp.o bnxt_xdp.o bnxt_vfr.o bnxt_tc.o

drivers/net/ethernet/broadcom/bnxt/bnxt.c

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
#include <linux/bitmap.h>
5151
#include <linux/cpu_rmap.h>
5252
#include <linux/cpumask.h>
53+
#include <net/pkt_cls.h>
5354

5455
#include "bnxt_hsi.h"
5556
#include "bnxt.h"
@@ -59,6 +60,7 @@
5960
#include "bnxt_dcb.h"
6061
#include "bnxt_xdp.h"
6162
#include "bnxt_vfr.h"
63+
#include "bnxt_tc.h"
6264

6365
#define BNXT_TX_TIMEOUT (5 * HZ)
6466

@@ -7305,17 +7307,33 @@ int bnxt_setup_mq_tc(struct net_device *dev, u8 tc)
73057307
return 0;
73067308
}
73077309

7308-
static int bnxt_setup_tc(struct net_device *dev, enum tc_setup_type type,
7309-
void *type_data)
7310+
static int bnxt_setup_flower(struct net_device *dev,
7311+
struct tc_cls_flower_offload *cls_flower)
73107312
{
7311-
struct tc_mqprio_qopt *mqprio = type_data;
7313+
struct bnxt *bp = netdev_priv(dev);
73127314

7313-
if (type != TC_SETUP_MQPRIO)
7315+
if (BNXT_VF(bp))
73147316
return -EOPNOTSUPP;
73157317

7316-
mqprio->hw = TC_MQPRIO_HW_OFFLOAD_TCS;
7318+
return bnxt_tc_setup_flower(bp, bp->pf.fw_fid, cls_flower);
7319+
}
7320+
7321+
static int bnxt_setup_tc(struct net_device *dev, enum tc_setup_type type,
7322+
void *type_data)
7323+
{
7324+
switch (type) {
7325+
case TC_SETUP_CLSFLOWER:
7326+
return bnxt_setup_flower(dev, type_data);
7327+
case TC_SETUP_MQPRIO: {
7328+
struct tc_mqprio_qopt *mqprio = type_data;
7329+
7330+
mqprio->hw = TC_MQPRIO_HW_OFFLOAD_TCS;
73177331

7318-
return bnxt_setup_mq_tc(dev, mqprio->num_tc);
7332+
return bnxt_setup_mq_tc(dev, mqprio->num_tc);
7333+
}
7334+
default:
7335+
return -EOPNOTSUPP;
7336+
}
73197337
}
73207338

73217339
#ifdef CONFIG_RFS_ACCEL
@@ -7711,6 +7729,7 @@ static void bnxt_remove_one(struct pci_dev *pdev)
77117729

77127730
pci_disable_pcie_error_reporting(pdev);
77137731
unregister_netdev(dev);
7732+
bnxt_shutdown_tc(bp);
77147733
cancel_work_sync(&bp->sp_task);
77157734
bp->sp_event = 0;
77167735

@@ -8102,9 +8121,12 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
81028121
else
81038122
device_set_wakeup_capable(&pdev->dev, false);
81048123

8124+
if (BNXT_PF(bp))
8125+
bnxt_init_tc(bp);
8126+
81058127
rc = register_netdev(dev);
81068128
if (rc)
8107-
goto init_err_clr_int;
8129+
goto init_err_cleanup_tc;
81088130

81098131
if (BNXT_PF(bp))
81108132
bnxt_dl_register(bp);
@@ -8117,7 +8139,8 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
81178139

81188140
return 0;
81198141

8120-
init_err_clr_int:
8142+
init_err_cleanup_tc:
8143+
bnxt_shutdown_tc(bp);
81218144
bnxt_clear_int_mode(bp);
81228145

81238146
init_err_pci_clean:

drivers/net/ethernet/broadcom/bnxt/bnxt.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#define DRV_VER_UPD 0
2020

2121
#include <linux/interrupt.h>
22+
#include <linux/rhashtable.h>
2223
#include <net/devlink.h>
2324
#include <net/dst_metadata.h>
2425
#include <net/switchdev.h>
@@ -943,6 +944,27 @@ struct bnxt_test_info {
943944
#define BNXT_CAG_REG_LEGACY_INT_STATUS 0x4014
944945
#define BNXT_CAG_REG_BASE 0x300000
945946

947+
struct bnxt_tc_info {
948+
bool enabled;
949+
950+
/* hash table to store TC offloaded flows */
951+
struct rhashtable flow_table;
952+
struct rhashtable_params flow_ht_params;
953+
954+
/* hash table to store L2 keys of TC flows */
955+
struct rhashtable l2_table;
956+
struct rhashtable_params l2_ht_params;
957+
958+
/* lock to atomically add/del an l2 node when a flow is
959+
* added or deleted.
960+
*/
961+
struct mutex lock;
962+
963+
/* Stat counter mask (width) */
964+
u64 bytes_mask;
965+
u64 packets_mask;
966+
};
967+
946968
struct bnxt_vf_rep_stats {
947969
u64 packets;
948970
u64 bytes;
@@ -1289,6 +1311,7 @@ struct bnxt {
12891311
enum devlink_eswitch_mode eswitch_mode;
12901312
struct bnxt_vf_rep **vf_reps; /* array of vf-rep ptrs */
12911313
u16 *cfa_code_map; /* cfa_code -> vf_idx map */
1314+
struct bnxt_tc_info tc_info;
12921315
};
12931316

12941317
#define BNXT_RX_STATS_OFFSET(counter) \

0 commit comments

Comments
 (0)