Skip to content

Commit e0a8b34

Browse files
Hariprasad Shenaidavem330
authored andcommitted
cxgb4vf: Add and initialize some sge params for VF driver
Add sge_vf_eq_qpp and sge_vf_iq_qpp to (struct sge_params), initialize sge_queues_per_page and sge_vf_qpp in t4vf_get_sge_params(), add new t4vf_prep_adapter() which initializes basic adapter parameters. Grab both SGE_EGRESS_QUEUES_PER_PAGE_VF and SGE_INGRESS_QUEUES_PER_PAGE_VF for VF Drivers since we need both to calculate the User Doorbell area offsets for Egress and Ingress Queues. Based on original work by Casey Leedom <[email protected]> Signed-off-by: Hariprasad Shenai <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 88b17b6 commit e0a8b34

File tree

4 files changed

+120
-5
lines changed

4 files changed

+120
-5
lines changed

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,13 @@
164164
#define HOSTPAGESIZEPF0(x) ((x) << HOSTPAGESIZEPF0_SHIFT)
165165

166166
#define SGE_EGRESS_QUEUES_PER_PAGE_PF 0x1010
167-
#define QUEUESPERPAGEPF0_MASK 0x0000000fU
168-
#define QUEUESPERPAGEPF0_GET(x) ((x) & QUEUESPERPAGEPF0_MASK)
167+
#define SGE_EGRESS_QUEUES_PER_PAGE_VF_A 0x1014
168+
169+
#define QUEUESPERPAGEPF1_S 4
170+
171+
#define QUEUESPERPAGEPF0_S 0
172+
#define QUEUESPERPAGEPF0_MASK 0x0000000fU
173+
#define QUEUESPERPAGEPF0_GET(x) ((x) & QUEUESPERPAGEPF0_MASK)
169174

170175
#define QUEUESPERPAGEPF0 0
171176
#define QUEUESPERPAGEPF1 4
@@ -323,6 +328,7 @@
323328
#define SGE_DEBUG_DATA_LOW_INDEX_3 0x12cc
324329
#define SGE_DEBUG_DATA_HIGH_INDEX_10 0x12a8
325330
#define SGE_INGRESS_QUEUES_PER_PAGE_PF 0x10f4
331+
#define SGE_INGRESS_QUEUES_PER_PAGE_VF_A 0x10f8
326332

327333
#define S_HP_INT_THRESH 28
328334
#define M_HP_INT_THRESH 0xfU

drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2594,6 +2594,27 @@ static int cxgb4vf_pci_probe(struct pci_dev *pdev,
25942594
goto err_free_adapter;
25952595
}
25962596

2597+
/* Wait for the device to become ready before proceeding ...
2598+
*/
2599+
err = t4vf_prep_adapter(adapter);
2600+
if (err) {
2601+
dev_err(adapter->pdev_dev, "device didn't become ready:"
2602+
" err=%d\n", err);
2603+
goto err_unmap_bar0;
2604+
}
2605+
2606+
/* For T5 and later we want to use the new BAR-based User Doorbells,
2607+
* so we need to map BAR2 here ...
2608+
*/
2609+
if (!is_t4(adapter->params.chip)) {
2610+
adapter->bar2 = ioremap_wc(pci_resource_start(pdev, 2),
2611+
pci_resource_len(pdev, 2));
2612+
if (!adapter->bar2) {
2613+
dev_err(adapter->pdev_dev, "cannot map BAR2 doorbells\n");
2614+
err = -ENOMEM;
2615+
goto err_unmap_bar0;
2616+
}
2617+
}
25972618
/*
25982619
* Initialize adapter level features.
25992620
*/
@@ -2786,6 +2807,10 @@ static int cxgb4vf_pci_probe(struct pci_dev *pdev,
27862807
}
27872808

27882809
err_unmap_bar:
2810+
if (!is_t4(adapter->params.chip))
2811+
iounmap(adapter->bar2);
2812+
2813+
err_unmap_bar0:
27892814
iounmap(adapter->regs);
27902815

27912816
err_free_adapter:
@@ -2856,6 +2881,8 @@ static void cxgb4vf_pci_remove(struct pci_dev *pdev)
28562881
free_netdev(netdev);
28572882
}
28582883
iounmap(adapter->regs);
2884+
if (!is_t4(adapter->params.chip))
2885+
iounmap(adapter->bar2);
28592886
kfree(adapter);
28602887
}
28612888

drivers/net/ethernet/chelsio/cxgb4vf/t4vf_common.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,11 @@ struct dev_params {
135135
struct sge_params {
136136
u32 sge_control; /* padding, boundaries, lengths, etc. */
137137
u32 sge_control2; /* T5: more of the same */
138-
u32 sge_host_page_size; /* RDMA page sizes */
139-
u32 sge_queues_per_page; /* RDMA queues/page */
140-
u32 sge_user_mode_limits; /* limits for BAR2 user mode accesses */
138+
u32 sge_host_page_size; /* PF0-7 page sizes */
139+
u32 sge_egress_queues_per_page; /* PF0-7 egress queues/page */
140+
u32 sge_ingress_queues_per_page;/* PF0-7 ingress queues/page */
141+
u32 sge_vf_eq_qpp; /* egress queues/page for our VF */
142+
u32 sge_vf_iq_qpp; /* ingress queues/page for our VF */
141143
u32 sge_fl_buffer_size[16]; /* free list buffer sizes */
142144
u32 sge_ingress_rx_threshold; /* RX counter interrupt threshold[4] */
143145
u32 sge_congestion_control; /* congestion thresholds, etc. */
@@ -267,6 +269,8 @@ static inline int t4vf_wr_mbox_ns(struct adapter *adapter, const void *cmd,
267269
return t4vf_wr_mbox_core(adapter, cmd, size, rpl, false);
268270
}
269271

272+
#define CHELSIO_PCI_ID_VER(dev_id) ((dev_id) >> 12)
273+
270274
static inline int is_t4(enum chip_type chip)
271275
{
272276
return CHELSIO_CHIP_VERSION(chip) == CHELSIO_T4;
@@ -309,5 +313,6 @@ int t4vf_iq_free(struct adapter *, unsigned int, unsigned int, unsigned int,
309313
int t4vf_eth_eq_free(struct adapter *, unsigned int);
310314

311315
int t4vf_handle_fw_rpl(struct adapter *, const __be64 *);
316+
int t4vf_prep_adapter(struct adapter *);
312317

313318
#endif /* __T4VF_COMMON_H__ */

drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,48 @@ int t4vf_get_sge_params(struct adapter *adapter)
501501
sge_params->sge_ingress_rx_threshold = vals[0];
502502
sge_params->sge_congestion_control = vals[1];
503503

504+
/* For T5 and later we want to use the new BAR2 Doorbells.
505+
* Unfortunately, older firmware didn't allow the this register to be
506+
* read.
507+
*/
508+
if (!is_t4(adapter->params.chip)) {
509+
u32 whoami;
510+
unsigned int pf, s_qpp;
511+
512+
params[0] = (FW_PARAMS_MNEM_V(FW_PARAMS_MNEM_REG) |
513+
FW_PARAMS_PARAM_XYZ_V(
514+
SGE_EGRESS_QUEUES_PER_PAGE_VF_A));
515+
params[1] = (FW_PARAMS_MNEM_V(FW_PARAMS_MNEM_REG) |
516+
FW_PARAMS_PARAM_XYZ_V(
517+
SGE_INGRESS_QUEUES_PER_PAGE_VF_A));
518+
v = t4vf_query_params(adapter, 2, params, vals);
519+
if (v != FW_SUCCESS) {
520+
dev_warn(adapter->pdev_dev,
521+
"Unable to get VF SGE Queues/Page; "
522+
"probably old firmware.\n");
523+
return v;
524+
}
525+
sge_params->sge_egress_queues_per_page = vals[0];
526+
sge_params->sge_ingress_queues_per_page = vals[1];
527+
528+
/* We need the Queues/Page for our VF. This is based on the
529+
* PF from which we're instantiated and is indexed in the
530+
* register we just read. Do it once here so other code in
531+
* the driver can just use it.
532+
*/
533+
whoami = t4_read_reg(adapter,
534+
T4VF_PL_BASE_ADDR + A_PL_VF_WHOAMI);
535+
pf = SOURCEPF_GET(whoami);
536+
s_qpp = (QUEUESPERPAGEPF0_S +
537+
(QUEUESPERPAGEPF1_S - QUEUESPERPAGEPF0_S) * pf);
538+
sge_params->sge_vf_eq_qpp =
539+
((sge_params->sge_egress_queues_per_page >> s_qpp)
540+
& QUEUESPERPAGEPF0_MASK);
541+
sge_params->sge_vf_iq_qpp =
542+
((sge_params->sge_ingress_queues_per_page >> s_qpp)
543+
& QUEUESPERPAGEPF0_MASK);
544+
}
545+
504546
return 0;
505547
}
506548

@@ -1420,3 +1462,38 @@ int t4vf_handle_fw_rpl(struct adapter *adapter, const __be64 *rpl)
14201462
}
14211463
return 0;
14221464
}
1465+
1466+
/**
1467+
*/
1468+
int t4vf_prep_adapter(struct adapter *adapter)
1469+
{
1470+
int err;
1471+
unsigned int chipid;
1472+
1473+
/* Wait for the device to become ready before proceeding ...
1474+
*/
1475+
err = t4vf_wait_dev_ready(adapter);
1476+
if (err)
1477+
return err;
1478+
1479+
/* Default port and clock for debugging in case we can't reach
1480+
* firmware.
1481+
*/
1482+
adapter->params.nports = 1;
1483+
adapter->params.vfres.pmask = 1;
1484+
adapter->params.vpd.cclk = 50000;
1485+
1486+
adapter->params.chip = 0;
1487+
switch (CHELSIO_PCI_ID_VER(adapter->pdev->device)) {
1488+
case CHELSIO_T4:
1489+
adapter->params.chip |= CHELSIO_CHIP_CODE(CHELSIO_T4, 0);
1490+
break;
1491+
1492+
case CHELSIO_T5:
1493+
chipid = G_REV(t4_read_reg(adapter, A_PL_VF_REV));
1494+
adapter->params.chip |= CHELSIO_CHIP_CODE(CHELSIO_T5, chipid);
1495+
break;
1496+
}
1497+
1498+
return 0;
1499+
}

0 commit comments

Comments
 (0)