@@ -85,6 +85,40 @@ static struct bnxt_re_dev *bnxt_re_from_netdev(struct net_device *netdev);
85
85
static void bnxt_re_dev_uninit (struct bnxt_re_dev * rdev );
86
86
static int bnxt_re_hwrm_qcaps (struct bnxt_re_dev * rdev );
87
87
88
+ static int bnxt_re_hwrm_qcfg (struct bnxt_re_dev * rdev , u32 * db_len ,
89
+ u32 * offset );
90
+ static void bnxt_re_set_db_offset (struct bnxt_re_dev * rdev )
91
+ {
92
+ struct bnxt_qplib_chip_ctx * cctx ;
93
+ struct bnxt_en_dev * en_dev ;
94
+ struct bnxt_qplib_res * res ;
95
+ u32 l2db_len = 0 ;
96
+ u32 offset = 0 ;
97
+ u32 barlen ;
98
+ int rc ;
99
+
100
+ res = & rdev -> qplib_res ;
101
+ en_dev = rdev -> en_dev ;
102
+ cctx = rdev -> chip_ctx ;
103
+
104
+ /* Issue qcfg */
105
+ rc = bnxt_re_hwrm_qcfg (rdev , & l2db_len , & offset );
106
+ if (rc )
107
+ dev_info (rdev_to_dev (rdev ),
108
+ "Couldn't get DB bar size, Low latency framework is disabled\n" );
109
+ /* set register offsets for both UC and WC */
110
+ res -> dpi_tbl .ucreg .offset = res -> is_vf ? BNXT_QPLIB_DBR_VF_DB_OFFSET :
111
+ BNXT_QPLIB_DBR_PF_DB_OFFSET ;
112
+ res -> dpi_tbl .wcreg .offset = res -> dpi_tbl .ucreg .offset ;
113
+
114
+ /* If WC mapping is disabled by L2 driver then en_dev->l2_db_size
115
+ * is equal to the DB-Bar actual size. This indicates that L2
116
+ * is mapping entire bar as UC-. RoCE driver can't enable WC mapping
117
+ * in such cases and DB-push will be disabled.
118
+ */
119
+ barlen = pci_resource_len (res -> pdev , RCFW_DBR_PCI_BAR_REGION );
120
+ }
121
+
88
122
static void bnxt_re_set_drv_mode (struct bnxt_re_dev * rdev , u8 mode )
89
123
{
90
124
struct bnxt_qplib_chip_ctx * cctx ;
@@ -116,6 +150,7 @@ static int bnxt_re_setup_chip_ctx(struct bnxt_re_dev *rdev, u8 wqe_mode)
116
150
{
117
151
struct bnxt_qplib_chip_ctx * chip_ctx ;
118
152
struct bnxt_en_dev * en_dev ;
153
+ int rc ;
119
154
120
155
en_dev = rdev -> en_dev ;
121
156
@@ -134,6 +169,12 @@ static int bnxt_re_setup_chip_ctx(struct bnxt_re_dev *rdev, u8 wqe_mode)
134
169
rdev -> qplib_res .is_vf = BNXT_EN_VF (en_dev );
135
170
136
171
bnxt_re_set_drv_mode (rdev , wqe_mode );
172
+
173
+ bnxt_re_set_db_offset (rdev );
174
+ rc = bnxt_qplib_map_db_bar (& rdev -> qplib_res );
175
+ if (rc )
176
+ return rc ;
177
+
137
178
if (bnxt_qplib_determine_atomics (en_dev -> pdev ))
138
179
ibdev_info (& rdev -> ibdev ,
139
180
"platform doesn't support global atomics." );
@@ -343,6 +384,30 @@ static void bnxt_re_fill_fw_msg(struct bnxt_fw_msg *fw_msg, void *msg,
343
384
fw_msg -> timeout = timeout ;
344
385
}
345
386
387
+ /* Query device config using common hwrm */
388
+ static int bnxt_re_hwrm_qcfg (struct bnxt_re_dev * rdev , u32 * db_len ,
389
+ u32 * offset )
390
+ {
391
+ struct bnxt_en_dev * en_dev = rdev -> en_dev ;
392
+ struct hwrm_func_qcfg_output resp = {0 };
393
+ struct hwrm_func_qcfg_input req = {0 };
394
+ struct bnxt_fw_msg fw_msg ;
395
+ int rc ;
396
+
397
+ memset (& fw_msg , 0 , sizeof (fw_msg ));
398
+ bnxt_re_init_hwrm_hdr (rdev , (void * )& req ,
399
+ HWRM_FUNC_QCFG , -1 , -1 );
400
+ req .fid = cpu_to_le16 (0xffff );
401
+ bnxt_re_fill_fw_msg (& fw_msg , (void * )& req , sizeof (req ), (void * )& resp ,
402
+ sizeof (resp ), DFLT_HWRM_CMD_TIMEOUT );
403
+ rc = bnxt_send_msg (en_dev , & fw_msg );
404
+ if (!rc ) {
405
+ * db_len = PAGE_ALIGN (le16_to_cpu (resp .l2_doorbell_bar_size_kb ) * 1024 );
406
+ * offset = PAGE_ALIGN (le16_to_cpu (resp .legacy_l2_db_size_kb ) * 1024 );
407
+ }
408
+ return rc ;
409
+ }
410
+
346
411
/* Query function capabilities using common hwrm */
347
412
int bnxt_re_hwrm_qcaps (struct bnxt_re_dev * rdev )
348
413
{
@@ -847,7 +912,6 @@ static void bnxt_re_free_res(struct bnxt_re_dev *rdev)
847
912
848
913
if (rdev -> qplib_res .dpi_tbl .max ) {
849
914
bnxt_qplib_dealloc_dpi (& rdev -> qplib_res ,
850
- & rdev -> qplib_res .dpi_tbl ,
851
915
& rdev -> dpi_privileged );
852
916
}
853
917
if (rdev -> qplib_res .rcfw ) {
@@ -875,9 +939,9 @@ static int bnxt_re_alloc_res(struct bnxt_re_dev *rdev)
875
939
if (rc )
876
940
goto fail ;
877
941
878
- rc = bnxt_qplib_alloc_dpi (& rdev -> qplib_res . dpi_tbl ,
942
+ rc = bnxt_qplib_alloc_dpi (& rdev -> qplib_res ,
879
943
& rdev -> dpi_privileged ,
880
- rdev );
944
+ rdev , BNXT_QPLIB_DPI_TYPE_KERNEL );
881
945
if (rc )
882
946
goto dealloc_res ;
883
947
@@ -917,7 +981,6 @@ static int bnxt_re_alloc_res(struct bnxt_re_dev *rdev)
917
981
bnxt_qplib_free_nq (& rdev -> nq [i ]);
918
982
}
919
983
bnxt_qplib_dealloc_dpi (& rdev -> qplib_res ,
920
- & rdev -> qplib_res .dpi_tbl ,
921
984
& rdev -> dpi_privileged );
922
985
dealloc_res :
923
986
bnxt_qplib_free_res (& rdev -> qplib_res );
0 commit comments