Skip to content

Commit b1396c2

Browse files
chelsiocudbgdavem330
authored andcommitted
cxgb4: parse and configure TC-MQPRIO offload
Add logic for validation and configuration of TC-MQPRIO Qdisc offload. Also, add support to manage EOSW_TXQ, which have 1-to-1 mapping with EOTIDs, and expose them to network stack. Move common skb validation in Tx path to a separate function and add minimal Tx path for ETHOFLD. Update Tx queue selection to return normal NIC Txq to send traffic pattern that can't go through ETHOFLD Tx path. Signed-off-by: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 76c3a55 commit b1396c2

File tree

7 files changed

+597
-50
lines changed

7 files changed

+597
-50
lines changed

drivers/net/ethernet/chelsio/cxgb4/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ obj-$(CONFIG_CHELSIO_T4) += cxgb4.o
88
cxgb4-objs := cxgb4_main.o l2t.o smt.o t4_hw.o sge.o clip_tbl.o cxgb4_ethtool.o \
99
cxgb4_uld.o srq.o sched.o cxgb4_filter.o cxgb4_tc_u32.o \
1010
cxgb4_ptp.o cxgb4_tc_flower.o cxgb4_cudbg.o cxgb4_mps.o \
11-
cudbg_common.o cudbg_lib.o cudbg_zlib.o
11+
cudbg_common.o cudbg_lib.o cudbg_zlib.o cxgb4_tc_mqprio.o
1212
cxgb4-$(CONFIG_CHELSIO_T4_DCB) += cxgb4_dcb.o
1313
cxgb4-$(CONFIG_CHELSIO_T4_FCOE) += cxgb4_fcoe.o
1414
cxgb4-$(CONFIG_DEBUG_FS) += cxgb4_debugfs.o

drivers/net/ethernet/chelsio/cxgb4/cxgb4.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,38 @@ struct sge_uld_txq_info {
803803
u16 ntxq; /* # of egress uld queues */
804804
};
805805

806+
enum sge_eosw_state {
807+
CXGB4_EO_STATE_CLOSED = 0, /* Not ready to accept traffic */
808+
};
809+
810+
struct sge_eosw_desc {
811+
struct sk_buff *skb; /* SKB to free after getting completion */
812+
dma_addr_t addr[MAX_SKB_FRAGS + 1]; /* DMA mapped addresses */
813+
};
814+
815+
struct sge_eosw_txq {
816+
spinlock_t lock; /* Per queue lock to synchronize completions */
817+
enum sge_eosw_state state; /* Current ETHOFLD State */
818+
struct sge_eosw_desc *desc; /* Descriptor ring to hold packets */
819+
u32 ndesc; /* Number of descriptors */
820+
u32 pidx; /* Current Producer Index */
821+
u32 last_pidx; /* Last successfully transmitted Producer Index */
822+
u32 cidx; /* Current Consumer Index */
823+
u32 last_cidx; /* Last successfully reclaimed Consumer Index */
824+
u32 inuse; /* Number of packets held in ring */
825+
826+
u32 cred; /* Current available credits */
827+
u32 ncompl; /* # of completions posted */
828+
u32 last_compl; /* # of credits consumed since last completion req */
829+
830+
u32 eotid; /* Index into EOTID table in software */
831+
u32 hwtid; /* Hardware EOTID index */
832+
833+
u32 hwqid; /* Underlying hardware queue index */
834+
struct net_device *netdev; /* Pointer to netdevice */
835+
struct tasklet_struct qresume_tsk; /* Restarts the queue */
836+
};
837+
806838
struct sge {
807839
struct sge_eth_txq ethtxq[MAX_ETH_QSETS];
808840
struct sge_eth_txq ptptxq;
@@ -1044,6 +1076,9 @@ struct adapter {
10441076
#if IS_ENABLED(CONFIG_THERMAL)
10451077
struct ch_thermal ch_thermal;
10461078
#endif
1079+
1080+
/* TC MQPRIO offload */
1081+
struct cxgb4_tc_mqprio *tc_mqprio;
10471082
};
10481083

10491084
/* Support for "sched-class" command to allow a TX Scheduling Class to be
@@ -1895,6 +1930,9 @@ int t4_i2c_rd(struct adapter *adap, unsigned int mbox, int port,
18951930
void free_rspq_fl(struct adapter *adap, struct sge_rspq *rq, struct sge_fl *fl);
18961931
void free_tx_desc(struct adapter *adap, struct sge_txq *q,
18971932
unsigned int n, bool unmap);
1933+
void cxgb4_eosw_txq_free_desc(struct adapter *adap, struct sge_eosw_txq *txq,
1934+
u32 ndesc);
1935+
void cxgb4_ethofld_restart(unsigned long data);
18981936
void free_txq(struct adapter *adap, struct sge_txq *q);
18991937
void cxgb4_reclaim_completed_tx(struct adapter *adap,
19001938
struct sge_txq *q, bool unmap);
@@ -1955,4 +1993,6 @@ int cxgb4_update_mac_filt(struct port_info *pi, unsigned int viid,
19551993
bool persistent, u8 *smt_idx);
19561994
int cxgb4_get_msix_idx_from_bmap(struct adapter *adap);
19571995
void cxgb4_free_msix_idx_in_bmap(struct adapter *adap, u32 msix_idx);
1996+
int cxgb_open(struct net_device *dev);
1997+
int cxgb_close(struct net_device *dev);
19581998
#endif /* __CXGB4_H__ */

drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
#include <linux/uaccess.h>
6666
#include <linux/crash_dump.h>
6767
#include <net/udp_tunnel.h>
68+
#include <net/xfrm.h>
6869

6970
#include "cxgb4.h"
7071
#include "cxgb4_filter.h"
@@ -82,6 +83,7 @@
8283
#include "sched.h"
8384
#include "cxgb4_tc_u32.h"
8485
#include "cxgb4_tc_flower.h"
86+
#include "cxgb4_tc_mqprio.h"
8587
#include "cxgb4_ptp.h"
8688
#include "cxgb4_cudbg.h"
8789

@@ -1117,6 +1119,18 @@ static u16 cxgb_select_queue(struct net_device *dev, struct sk_buff *skb,
11171119
}
11181120
#endif /* CONFIG_CHELSIO_T4_DCB */
11191121

1122+
if (dev->num_tc) {
1123+
struct port_info *pi = netdev2pinfo(dev);
1124+
1125+
/* Send unsupported traffic pattern to normal NIC queues. */
1126+
txq = netdev_pick_tx(dev, skb, sb_dev);
1127+
if (xfrm_offload(skb) || is_ptp_enabled(skb, dev) ||
1128+
ip_hdr(skb)->protocol != IPPROTO_TCP)
1129+
txq = txq % pi->nqsets;
1130+
1131+
return txq;
1132+
}
1133+
11201134
if (select_queue) {
11211135
txq = (skb_rx_queue_recorded(skb)
11221136
? skb_get_rx_queue(skb)
@@ -2472,11 +2486,11 @@ static void cxgb_down(struct adapter *adapter)
24722486
/*
24732487
* net_device operations
24742488
*/
2475-
static int cxgb_open(struct net_device *dev)
2489+
int cxgb_open(struct net_device *dev)
24762490
{
2477-
int err;
24782491
struct port_info *pi = netdev_priv(dev);
24792492
struct adapter *adapter = pi->adapter;
2493+
int err;
24802494

24812495
netif_carrier_off(dev);
24822496

@@ -2499,7 +2513,7 @@ static int cxgb_open(struct net_device *dev)
24992513
return err;
25002514
}
25012515

2502-
static int cxgb_close(struct net_device *dev)
2516+
int cxgb_close(struct net_device *dev)
25032517
{
25042518
struct port_info *pi = netdev_priv(dev);
25052519
struct adapter *adapter = pi->adapter;
@@ -3233,6 +3247,17 @@ static int cxgb_setup_tc_block_cb(enum tc_setup_type type, void *type_data,
32333247
}
32343248
}
32353249

3250+
static int cxgb_setup_tc_mqprio(struct net_device *dev,
3251+
struct tc_mqprio_qopt_offload *mqprio)
3252+
{
3253+
struct adapter *adap = netdev2adap(dev);
3254+
3255+
if (!is_ethofld(adap) || !adap->tc_mqprio)
3256+
return -ENOMEM;
3257+
3258+
return cxgb4_setup_tc_mqprio(dev, mqprio);
3259+
}
3260+
32363261
static LIST_HEAD(cxgb_block_cb_list);
32373262

32383263
static int cxgb_setup_tc(struct net_device *dev, enum tc_setup_type type,
@@ -3241,6 +3266,8 @@ static int cxgb_setup_tc(struct net_device *dev, enum tc_setup_type type,
32413266
struct port_info *pi = netdev2pinfo(dev);
32423267

32433268
switch (type) {
3269+
case TC_SETUP_QDISC_MQPRIO:
3270+
return cxgb_setup_tc_mqprio(dev, type_data);
32443271
case TC_SETUP_BLOCK:
32453272
return flow_block_cb_setup_simple(type_data,
32463273
&cxgb_block_cb_list,
@@ -5668,6 +5695,7 @@ static void free_some_resources(struct adapter *adapter)
56685695
kvfree(adapter->srq);
56695696
t4_cleanup_sched(adapter);
56705697
kvfree(adapter->tids.tid_tab);
5698+
cxgb4_cleanup_tc_mqprio(adapter);
56715699
cxgb4_cleanup_tc_flower(adapter);
56725700
cxgb4_cleanup_tc_u32(adapter);
56735701
kfree(adapter->sge.egr_map);
@@ -6237,6 +6265,10 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
62376265
if (cxgb4_init_tc_flower(adapter))
62386266
dev_warn(&pdev->dev,
62396267
"could not offload tc flower, continuing\n");
6268+
6269+
if (cxgb4_init_tc_mqprio(adapter))
6270+
dev_warn(&pdev->dev,
6271+
"could not offload tc mqprio, continuing\n");
62406272
}
62416273

62426274
if (is_offload(adapter) || is_hashfilter(adapter)) {

0 commit comments

Comments
 (0)