hc
2024-01-05 071106ecf68c401173c58808b1cf5f68cc50d390
kernel/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c
....@@ -43,7 +43,7 @@
4343 netdev_dbg(bp->dev, "tx_cfa_action=0x%x, rx_cfa_code=0x%x",
4444 *tx_cfa_action, *rx_cfa_code);
4545 } else {
46
- netdev_info(bp->dev, "%s error rc=%d", __func__, rc);
46
+ netdev_info(bp->dev, "%s error rc=%d\n", __func__, rc);
4747 }
4848
4949 mutex_unlock(&bp->hwrm_cmd_lock);
....@@ -60,7 +60,7 @@
6060
6161 rc = hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
6262 if (rc)
63
- netdev_info(bp->dev, "%s error rc=%d", __func__, rc);
63
+ netdev_info(bp->dev, "%s error rc=%d\n", __func__, rc);
6464 return rc;
6565 }
6666
....@@ -161,34 +161,19 @@
161161 }
162162 }
163163
164
-static int bnxt_vf_rep_setup_tc_block(struct net_device *dev,
165
- struct tc_block_offload *f)
166
-{
167
- struct bnxt_vf_rep *vf_rep = netdev_priv(dev);
168
-
169
- if (f->binder_type != TCF_BLOCK_BINDER_TYPE_CLSACT_INGRESS)
170
- return -EOPNOTSUPP;
171
-
172
- switch (f->command) {
173
- case TC_BLOCK_BIND:
174
- return tcf_block_cb_register(f->block,
175
- bnxt_vf_rep_setup_tc_block_cb,
176
- vf_rep, vf_rep, f->extack);
177
- case TC_BLOCK_UNBIND:
178
- tcf_block_cb_unregister(f->block,
179
- bnxt_vf_rep_setup_tc_block_cb, vf_rep);
180
- return 0;
181
- default:
182
- return -EOPNOTSUPP;
183
- }
184
-}
164
+static LIST_HEAD(bnxt_vf_block_cb_list);
185165
186166 static int bnxt_vf_rep_setup_tc(struct net_device *dev, enum tc_setup_type type,
187167 void *type_data)
188168 {
169
+ struct bnxt_vf_rep *vf_rep = netdev_priv(dev);
170
+
189171 switch (type) {
190172 case TC_SETUP_BLOCK:
191
- return bnxt_vf_rep_setup_tc_block(dev, type_data);
173
+ return flow_block_cb_setup_simple(type_data,
174
+ &bnxt_vf_block_cb_list,
175
+ bnxt_vf_rep_setup_tc_block_cb,
176
+ vf_rep, vf_rep, true);
192177 default:
193178 return -EOPNOTSUPP;
194179 }
....@@ -209,9 +194,7 @@
209194 void bnxt_vf_rep_rx(struct bnxt *bp, struct sk_buff *skb)
210195 {
211196 struct bnxt_vf_rep *vf_rep = netdev_priv(skb->dev);
212
- struct bnxt_vf_rep_stats *rx_stats;
213197
214
- rx_stats = &vf_rep->rx_stats;
215198 vf_rep->rx_stats.bytes += skb->len;
216199 vf_rep->rx_stats.packets++;
217200
....@@ -236,23 +219,18 @@
236219 struct ethtool_drvinfo *info)
237220 {
238221 strlcpy(info->driver, DRV_MODULE_NAME, sizeof(info->driver));
239
- strlcpy(info->version, DRV_MODULE_VERSION, sizeof(info->version));
240222 }
241223
242
-static int bnxt_vf_rep_port_attr_get(struct net_device *dev,
243
- struct switchdev_attr *attr)
224
+static int bnxt_vf_rep_get_port_parent_id(struct net_device *dev,
225
+ struct netdev_phys_item_id *ppid)
244226 {
245227 struct bnxt_vf_rep *vf_rep = netdev_priv(dev);
246228
247229 /* as only PORT_PARENT_ID is supported currently use common code
248230 * between PF and VF-rep for now.
249231 */
250
- return bnxt_port_attr_get(vf_rep->bp, attr);
232
+ return bnxt_get_port_parent_id(vf_rep->bp->dev, ppid);
251233 }
252
-
253
-static const struct switchdev_ops bnxt_vf_rep_switchdev_ops = {
254
- .switchdev_port_attr_get = bnxt_vf_rep_port_attr_get
255
-};
256234
257235 static const struct ethtool_ops bnxt_vf_rep_ethtool_ops = {
258236 .get_drvinfo = bnxt_vf_rep_get_drvinfo
....@@ -264,6 +242,7 @@
264242 .ndo_start_xmit = bnxt_vf_rep_xmit,
265243 .ndo_get_stats64 = bnxt_vf_rep_get_stats64,
266244 .ndo_setup_tc = bnxt_vf_rep_setup_tc,
245
+ .ndo_get_port_parent_id = bnxt_vf_rep_get_port_parent_id,
267246 .ndo_get_phys_port_name = bnxt_vf_rep_get_phys_port_name
268247 };
269248
....@@ -394,7 +373,6 @@
394373
395374 dev->netdev_ops = &bnxt_vf_rep_netdev_ops;
396375 dev->ethtool_ops = &bnxt_vf_rep_ethtool_ops;
397
- SWITCHDEV_SET_OPS(dev, &bnxt_vf_rep_switchdev_ops);
398376 /* Just inherit all the featues of the parent PF as the VF-R
399377 * uses the RX/TX rings of the parent PF
400378 */
....@@ -412,32 +390,15 @@
412390 dev->min_mtu = ETH_ZLEN;
413391 }
414392
415
-static int bnxt_pcie_dsn_get(struct bnxt *bp, u8 dsn[])
416
-{
417
- struct pci_dev *pdev = bp->pdev;
418
- int pos = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_DSN);
419
- u32 dw;
420
-
421
- if (!pos) {
422
- netdev_info(bp->dev, "Unable do read adapter's DSN");
423
- return -EOPNOTSUPP;
424
- }
425
-
426
- /* DSN (two dw) is at an offset of 4 from the cap pos */
427
- pos += 4;
428
- pci_read_config_dword(pdev, pos, &dw);
429
- put_unaligned_le32(dw, &dsn[0]);
430
- pci_read_config_dword(pdev, pos + 4, &dw);
431
- put_unaligned_le32(dw, &dsn[4]);
432
- return 0;
433
-}
434
-
435393 static int bnxt_vf_reps_create(struct bnxt *bp)
436394 {
437395 u16 *cfa_code_map = NULL, num_vfs = pci_num_vf(bp->pdev);
438396 struct bnxt_vf_rep *vf_rep;
439397 struct net_device *dev;
440398 int rc, i;
399
+
400
+ if (!(bp->flags & BNXT_FLAG_DSN_VALID))
401
+ return -ENODEV;
441402
442403 bp->vf_reps = kcalloc(num_vfs, sizeof(vf_rep), GFP_KERNEL);
443404 if (!bp->vf_reps)
....@@ -496,11 +457,6 @@
496457 }
497458 }
498459
499
- /* Read the adapter's DSN to use as the eswitch switch_id */
500
- rc = bnxt_pcie_dsn_get(bp, bp->switch_id);
501
- if (rc)
502
- goto err;
503
-
504460 /* publish cfa_code_map only after all VF-reps have been initialized */
505461 bp->cfa_code_map = cfa_code_map;
506462 bp->eswitch_mode = DEVLINK_ESWITCH_MODE_SWITCHDEV;
....@@ -508,7 +464,7 @@
508464 return 0;
509465
510466 err:
511
- netdev_info(bp->dev, "%s error=%d", __func__, rc);
467
+ netdev_info(bp->dev, "%s error=%d\n", __func__, rc);
512468 kfree(cfa_code_map);
513469 __bnxt_vf_reps_destroy(bp);
514470 return rc;
....@@ -523,14 +479,15 @@
523479 return 0;
524480 }
525481
526
-int bnxt_dl_eswitch_mode_set(struct devlink *devlink, u16 mode)
482
+int bnxt_dl_eswitch_mode_set(struct devlink *devlink, u16 mode,
483
+ struct netlink_ext_ack *extack)
527484 {
528485 struct bnxt *bp = bnxt_get_bp_from_dl(devlink);
529486 int rc = 0;
530487
531488 mutex_lock(&bp->sriov_lock);
532489 if (bp->eswitch_mode == mode) {
533
- netdev_info(bp->dev, "already in %s eswitch mode",
490
+ netdev_info(bp->dev, "already in %s eswitch mode\n",
534491 mode == DEVLINK_ESWITCH_MODE_LEGACY ?
535492 "legacy" : "switchdev");
536493 rc = -EINVAL;
....@@ -550,7 +507,7 @@
550507 }
551508
552509 if (pci_num_vf(bp->pdev) == 0) {
553
- netdev_info(bp->dev, "Enable VFs before setting switchdev mode");
510
+ netdev_info(bp->dev, "Enable VFs before setting switchdev mode\n");
554511 rc = -EPERM;
555512 goto done;
556513 }