Skip to content

Commit 94cdb8b

Browse files
Hariprasad Shenaidavem330
authored andcommitted
cxgb4: Add support for dynamic allocation of resources for ULD
Add a new commmon infrastructure to allocate reosurces dynamically to Upper layer driver's(ULD) when they register with cxgb4 driver and free them during unregistering. All the queues and the interrupts for them will be allocated during ULD probe only and freed during remove. Signed-off-by: Atul Gupta <[email protected]> Signed-off-by: Hariprasad Shenai <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b65b24d commit 94cdb8b

File tree

7 files changed

+759
-50
lines changed

7 files changed

+759
-50
lines changed

drivers/net/ethernet/chelsio/cxgb4/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
obj-$(CONFIG_CHELSIO_T4) += cxgb4.o
66

7-
cxgb4-objs := cxgb4_main.o l2t.o t4_hw.o sge.o clip_tbl.o cxgb4_ethtool.o
7+
cxgb4-objs := cxgb4_main.o l2t.o t4_hw.o sge.o clip_tbl.o cxgb4_ethtool.o cxgb4_uld.o
88
cxgb4-$(CONFIG_CHELSIO_T4_DCB) += cxgb4_dcb.o
99
cxgb4-$(CONFIG_CHELSIO_T4_FCOE) += cxgb4_fcoe.o
1010
cxgb4-$(CONFIG_DEBUG_FS) += cxgb4_debugfs.o

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

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@
5353
#include "cxgb4_uld.h"
5454

5555
#define CH_WARN(adap, fmt, ...) dev_warn(adap->pdev_dev, fmt, ## __VA_ARGS__)
56+
extern struct list_head adapter_list;
57+
extern struct mutex uld_mutex;
5658

5759
enum {
5860
MAX_NPORTS = 4, /* max # of ports */
@@ -338,6 +340,7 @@ struct adapter_params {
338340
enum chip_type chip; /* chip code */
339341
struct arch_specific_params arch; /* chip specific params */
340342
unsigned char offload;
343+
unsigned char crypto; /* HW capability for crypto */
341344

342345
unsigned char bypass;
343346

@@ -403,7 +406,6 @@ struct fw_info {
403406
struct fw_hdr fw_hdr;
404407
};
405408

406-
407409
struct trace_params {
408410
u32 data[TRACE_LEN / 4];
409411
u32 mask[TRACE_LEN / 4];
@@ -510,6 +512,10 @@ enum { /* adapter flags */
510512
FW_OFLD_CONN = (1 << 9),
511513
};
512514

515+
enum {
516+
ULP_CRYPTO_LOOKASIDE = 1 << 0,
517+
};
518+
513519
struct rx_sw_desc;
514520

515521
struct sge_fl { /* SGE free-buffer queue state */
@@ -680,6 +686,16 @@ struct sge_ctrl_txq { /* state for an SGE control Tx queue */
680686
u8 full; /* the Tx ring is full */
681687
} ____cacheline_aligned_in_smp;
682688

689+
struct sge_uld_rxq_info {
690+
char name[IFNAMSIZ]; /* name of ULD driver */
691+
struct sge_ofld_rxq *uldrxq; /* Rxq's for ULD */
692+
u16 *msix_tbl; /* msix_tbl for uld */
693+
u16 *rspq_id; /* response queue id's of rxq */
694+
u16 nrxq; /* # of ingress uld queues */
695+
u16 nciq; /* # of completion queues */
696+
u8 uld; /* uld type */
697+
};
698+
683699
struct sge {
684700
struct sge_eth_txq ethtxq[MAX_ETH_QSETS];
685701
struct sge_ofld_txq ofldtxq[MAX_OFLD_QSETS];
@@ -691,6 +707,7 @@ struct sge {
691707
struct sge_ofld_rxq rdmarxq[MAX_RDMA_QUEUES];
692708
struct sge_ofld_rxq rdmaciq[MAX_RDMA_CIQS];
693709
struct sge_rspq fw_evtq ____cacheline_aligned_in_smp;
710+
struct sge_uld_rxq_info **uld_rxq_info;
694711

695712
struct sge_rspq intrq ____cacheline_aligned_in_smp;
696713
spinlock_t intrq_lock;
@@ -702,6 +719,7 @@ struct sge {
702719
u16 niscsitq; /* # of available iSCST Rx queues */
703720
u16 rdmaqs; /* # of available RDMA Rx queues */
704721
u16 rdmaciqs; /* # of available RDMA concentrator IQs */
722+
u16 nqs_per_uld; /* # of Rx queues per ULD */
705723
u16 iscsi_rxq[MAX_OFLD_QSETS];
706724
u16 iscsit_rxq[MAX_ISCSIT_QUEUES];
707725
u16 rdma_rxq[MAX_RDMA_QUEUES];
@@ -757,6 +775,17 @@ struct hash_mac_addr {
757775
u8 addr[ETH_ALEN];
758776
};
759777

778+
struct uld_msix_bmap {
779+
unsigned long *msix_bmap;
780+
unsigned int mapsize;
781+
spinlock_t lock; /* lock for acquiring bitmap */
782+
};
783+
784+
struct uld_msix_info {
785+
unsigned short vec;
786+
char desc[IFNAMSIZ + 10];
787+
};
788+
760789
struct adapter {
761790
void __iomem *regs;
762791
void __iomem *bar2;
@@ -779,6 +808,9 @@ struct adapter {
779808
unsigned short vec;
780809
char desc[IFNAMSIZ + 10];
781810
} msix_info[MAX_INGQ + 1];
811+
struct uld_msix_info *msix_info_ulds; /* msix info for uld's */
812+
struct uld_msix_bmap msix_bmap_ulds; /* msix bitmap for all uld */
813+
unsigned int msi_idx;
782814

783815
struct doorbell_stats db_stats;
784816
struct sge sge;
@@ -793,7 +825,9 @@ struct adapter {
793825
unsigned int clipt_start;
794826
unsigned int clipt_end;
795827
struct clip_tbl *clipt;
828+
struct cxgb4_pci_uld_info *uld;
796829
void *uld_handle[CXGB4_ULD_MAX];
830+
unsigned int num_uld;
797831
struct list_head list_node;
798832
struct list_head rcu_node;
799833
struct list_head mac_hlist; /* list of MAC addresses in MPS Hash */
@@ -952,6 +986,11 @@ static inline int is_offload(const struct adapter *adap)
952986
return adap->params.offload;
953987
}
954988

989+
static inline int is_pci_uld(const struct adapter *adap)
990+
{
991+
return adap->params.crypto;
992+
}
993+
955994
static inline u32 t4_read_reg(struct adapter *adap, u32 reg_addr)
956995
{
957996
return readl(adap->regs + reg_addr);
@@ -1185,8 +1224,6 @@ int t4_sge_init(struct adapter *adap);
11851224
void t4_sge_start(struct adapter *adap);
11861225
void t4_sge_stop(struct adapter *adap);
11871226
int cxgb_busy_poll(struct napi_struct *napi);
1188-
int cxgb4_set_rspq_intr_params(struct sge_rspq *q, unsigned int us,
1189-
unsigned int cnt);
11901227
void cxgb4_set_ethtool_ops(struct net_device *netdev);
11911228
int cxgb4_write_rss(const struct port_info *pi, const u16 *queues);
11921229
extern int dbfifo_int_thresh;
@@ -1289,6 +1326,18 @@ static inline int hash_mac_addr(const u8 *addr)
12891326
return a & 0x3f;
12901327
}
12911328

1329+
int cxgb4_set_rspq_intr_params(struct sge_rspq *q, unsigned int us,
1330+
unsigned int cnt);
1331+
static inline void init_rspq(struct adapter *adap, struct sge_rspq *q,
1332+
unsigned int us, unsigned int cnt,
1333+
unsigned int size, unsigned int iqe_size)
1334+
{
1335+
q->adap = adap;
1336+
cxgb4_set_rspq_intr_params(q, us, cnt);
1337+
q->iqe_len = iqe_size;
1338+
q->size = size;
1339+
}
1340+
12921341
void t4_write_indirect(struct adapter *adap, unsigned int addr_reg,
12931342
unsigned int data_reg, const u32 *vals,
12941343
unsigned int nregs, unsigned int start_idx);
@@ -1523,5 +1572,7 @@ void t4_idma_monitor(struct adapter *adapter,
15231572
int hz, int ticks);
15241573
int t4_set_vf_mac_acl(struct adapter *adapter, unsigned int vf,
15251574
unsigned int naddr, u8 *addr);
1526-
1575+
void uld_mem_free(struct adapter *adap);
1576+
int uld_mem_alloc(struct adapter *adap);
1577+
void free_rspq_fl(struct adapter *adap, struct sge_rspq *rq, struct sge_fl *fl);
15271578
#endif /* __CXGB4_H__ */

0 commit comments

Comments
 (0)