hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c
....@@ -45,10 +45,8 @@
4545
4646 max_stat_ctxs = bnxt_get_max_func_stat_ctxs(bp);
4747 if (max_stat_ctxs <= BNXT_MIN_ROCE_STAT_CTXS ||
48
- bp->num_stat_ctxs == max_stat_ctxs)
48
+ bp->cp_nr_rings == max_stat_ctxs)
4949 return -ENOMEM;
50
- bnxt_set_max_func_stat_ctxs(bp, max_stat_ctxs -
51
- BNXT_MIN_ROCE_STAT_CTXS);
5250 }
5351
5452 atomic_set(&ulp->ref_count, 0);
....@@ -79,16 +77,11 @@
7977 netdev_err(bp->dev, "ulp id %d not registered\n", ulp_id);
8078 return -EINVAL;
8179 }
82
- if (ulp_id == BNXT_ROCE_ULP) {
83
- unsigned int max_stat_ctxs;
80
+ if (ulp_id == BNXT_ROCE_ULP && ulp->msix_requested)
81
+ edev->en_ops->bnxt_free_msix(edev, ulp_id);
8482
85
- max_stat_ctxs = bnxt_get_max_func_stat_ctxs(bp);
86
- bnxt_set_max_func_stat_ctxs(bp, max_stat_ctxs + 1);
87
- if (ulp->msix_requested)
88
- edev->en_ops->bnxt_free_msix(edev, ulp_id);
89
- }
9083 if (ulp->max_async_event_id)
91
- bnxt_hwrm_func_rgtr_async_events(bp, NULL, 0);
84
+ bnxt_hwrm_func_drv_rgtr(bp, NULL, 0, true);
9285
9386 RCU_INIT_POINTER(ulp->ulp_ops, NULL);
9487 synchronize_rcu();
....@@ -111,7 +104,13 @@
111104 for (i = 0; i < num_msix; i++) {
112105 ent[i].vector = bp->irq_tbl[idx + i].vector;
113106 ent[i].ring_idx = idx + i;
114
- ent[i].db_offset = (idx + i) * 0x80;
107
+ if (bp->flags & BNXT_FLAG_CHIP_P5) {
108
+ ent[i].db_offset = DB_PF_OFFSET_P5;
109
+ if (BNXT_VF(bp))
110
+ ent[i].db_offset = DB_VF_OFFSET_P5;
111
+ } else {
112
+ ent[i].db_offset = (idx + i) * 0x80;
113
+ }
115114 }
116115 }
117116
....@@ -120,8 +119,10 @@
120119 {
121120 struct net_device *dev = edev->net;
122121 struct bnxt *bp = netdev_priv(dev);
122
+ struct bnxt_hw_resc *hw_resc;
123123 int max_idx, max_cp_rings;
124124 int avail_msix, idx;
125
+ int total_vecs;
125126 int rc = 0;
126127
127128 ASSERT_RTNL();
....@@ -149,12 +150,15 @@
149150 }
150151 edev->ulp_tbl[ulp_id].msix_base = idx;
151152 edev->ulp_tbl[ulp_id].msix_requested = avail_msix;
152
- if (bp->total_irqs < (idx + avail_msix)) {
153
+ hw_resc = &bp->hw_resc;
154
+ total_vecs = idx + avail_msix;
155
+ if (bp->total_irqs < total_vecs ||
156
+ (BNXT_NEW_RM(bp) && hw_resc->resv_irqs < total_vecs)) {
153157 if (netif_running(dev)) {
154158 bnxt_close_nic(bp, true, false);
155159 rc = bnxt_open_nic(bp, true, false);
156160 } else {
157
- rc = bnxt_reserve_rings(bp);
161
+ rc = bnxt_reserve_rings(bp, true);
158162 }
159163 }
160164 if (rc) {
....@@ -163,9 +167,10 @@
163167 }
164168
165169 if (BNXT_NEW_RM(bp)) {
166
- struct bnxt_hw_resc *hw_resc = &bp->hw_resc;
170
+ int resv_msix;
167171
168
- avail_msix = hw_resc->resv_cp_rings - bp->cp_nr_rings;
172
+ resv_msix = hw_resc->resv_irqs - bp->cp_nr_rings;
173
+ avail_msix = min_t(int, resv_msix, avail_msix);
169174 edev->ulp_tbl[ulp_id].msix_requested = avail_msix;
170175 }
171176 bnxt_fill_msix_vecs(bp, ent);
....@@ -187,7 +192,7 @@
187192
188193 edev->ulp_tbl[ulp_id].msix_requested = 0;
189194 edev->flags &= ~BNXT_EN_FLAG_MSIX_REQUESTED;
190
- if (netif_running(dev)) {
195
+ if (netif_running(dev) && !(edev->flags & BNXT_EN_FLAG_ULP_STOPPED)) {
191196 bnxt_close_nic(bp, true, false);
192197 bnxt_open_nic(bp, true, false);
193198 }
....@@ -215,6 +220,18 @@
215220 return 0;
216221 }
217222
223
+int bnxt_get_ulp_stat_ctxs(struct bnxt *bp)
224
+{
225
+ if (bnxt_ulp_registered(bp->edev, BNXT_ROCE_ULP)) {
226
+ struct bnxt_en_dev *edev = bp->edev;
227
+
228
+ if (edev->ulp_tbl[BNXT_ROCE_ULP].msix_requested)
229
+ return BNXT_MIN_ROCE_STAT_CTXS;
230
+ }
231
+
232
+ return 0;
233
+}
234
+
218235 static int bnxt_send_msg(struct bnxt_en_dev *edev, int ulp_id,
219236 struct bnxt_fw_msg *fw_msg)
220237 {
....@@ -222,6 +239,9 @@
222239 struct bnxt *bp = netdev_priv(dev);
223240 struct input *req;
224241 int rc;
242
+
243
+ if (ulp_id != BNXT_ROCE_ULP && bp->fw_reset_state)
244
+ return -EBUSY;
225245
226246 mutex_lock(&bp->hwrm_cmd_lock);
227247 req = fw_msg->msg;
....@@ -260,6 +280,7 @@
260280 if (!edev)
261281 return;
262282
283
+ edev->flags |= BNXT_EN_FLAG_ULP_STOPPED;
263284 for (i = 0; i < BNXT_MAX_ULP; i++) {
264285 struct bnxt_ulp *ulp = &edev->ulp_tbl[i];
265286
....@@ -270,13 +291,18 @@
270291 }
271292 }
272293
273
-void bnxt_ulp_start(struct bnxt *bp)
294
+void bnxt_ulp_start(struct bnxt *bp, int err)
274295 {
275296 struct bnxt_en_dev *edev = bp->edev;
276297 struct bnxt_ulp_ops *ops;
277298 int i;
278299
279300 if (!edev)
301
+ return;
302
+
303
+ edev->flags &= ~BNXT_EN_FLAG_ULP_STOPPED;
304
+
305
+ if (err)
280306 return;
281307
282308 for (i = 0; i < BNXT_MAX_ULP; i++) {
....@@ -429,7 +455,7 @@
429455 /* Make sure bnxt_ulp_async_events() sees this order */
430456 smp_wmb();
431457 ulp->max_async_event_id = max_id;
432
- bnxt_hwrm_func_rgtr_async_events(bp, events_bmap, max_id + 1);
458
+ bnxt_hwrm_func_drv_rgtr(bp, events_bmap, max_id + 1, true);
433459 return 0;
434460 }
435461
....@@ -453,13 +479,16 @@
453479 if (!edev)
454480 return ERR_PTR(-ENOMEM);
455481 edev->en_ops = &bnxt_en_ops_tbl;
456
- if (bp->flags & BNXT_FLAG_ROCEV1_CAP)
457
- edev->flags |= BNXT_EN_FLAG_ROCEV1_CAP;
458
- if (bp->flags & BNXT_FLAG_ROCEV2_CAP)
459
- edev->flags |= BNXT_EN_FLAG_ROCEV2_CAP;
460482 edev->net = dev;
461483 edev->pdev = bp->pdev;
484
+ edev->l2_db_size = bp->db_size;
485
+ edev->l2_db_size_nc = bp->db_size;
462486 bp->edev = edev;
463487 }
488
+ edev->flags &= ~BNXT_EN_FLAG_ROCE_CAP;
489
+ if (bp->flags & BNXT_FLAG_ROCEV1_CAP)
490
+ edev->flags |= BNXT_EN_FLAG_ROCEV1_CAP;
491
+ if (bp->flags & BNXT_FLAG_ROCEV2_CAP)
492
+ edev->flags |= BNXT_EN_FLAG_ROCEV2_CAP;
464493 return bp->edev;
465494 }