| .. | .. |
|---|
| 43 | 43 | netdev_dbg(bp->dev, "tx_cfa_action=0x%x, rx_cfa_code=0x%x", |
|---|
| 44 | 44 | *tx_cfa_action, *rx_cfa_code); |
|---|
| 45 | 45 | } else { |
|---|
| 46 | | - netdev_info(bp->dev, "%s error rc=%d", __func__, rc); |
|---|
| 46 | + netdev_info(bp->dev, "%s error rc=%d\n", __func__, rc); |
|---|
| 47 | 47 | } |
|---|
| 48 | 48 | |
|---|
| 49 | 49 | mutex_unlock(&bp->hwrm_cmd_lock); |
|---|
| .. | .. |
|---|
| 60 | 60 | |
|---|
| 61 | 61 | rc = hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); |
|---|
| 62 | 62 | 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); |
|---|
| 64 | 64 | return rc; |
|---|
| 65 | 65 | } |
|---|
| 66 | 66 | |
|---|
| .. | .. |
|---|
| 161 | 161 | } |
|---|
| 162 | 162 | } |
|---|
| 163 | 163 | |
|---|
| 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); |
|---|
| 185 | 165 | |
|---|
| 186 | 166 | static int bnxt_vf_rep_setup_tc(struct net_device *dev, enum tc_setup_type type, |
|---|
| 187 | 167 | void *type_data) |
|---|
| 188 | 168 | { |
|---|
| 169 | + struct bnxt_vf_rep *vf_rep = netdev_priv(dev); |
|---|
| 170 | + |
|---|
| 189 | 171 | switch (type) { |
|---|
| 190 | 172 | 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); |
|---|
| 192 | 177 | default: |
|---|
| 193 | 178 | return -EOPNOTSUPP; |
|---|
| 194 | 179 | } |
|---|
| .. | .. |
|---|
| 209 | 194 | void bnxt_vf_rep_rx(struct bnxt *bp, struct sk_buff *skb) |
|---|
| 210 | 195 | { |
|---|
| 211 | 196 | struct bnxt_vf_rep *vf_rep = netdev_priv(skb->dev); |
|---|
| 212 | | - struct bnxt_vf_rep_stats *rx_stats; |
|---|
| 213 | 197 | |
|---|
| 214 | | - rx_stats = &vf_rep->rx_stats; |
|---|
| 215 | 198 | vf_rep->rx_stats.bytes += skb->len; |
|---|
| 216 | 199 | vf_rep->rx_stats.packets++; |
|---|
| 217 | 200 | |
|---|
| .. | .. |
|---|
| 236 | 219 | struct ethtool_drvinfo *info) |
|---|
| 237 | 220 | { |
|---|
| 238 | 221 | strlcpy(info->driver, DRV_MODULE_NAME, sizeof(info->driver)); |
|---|
| 239 | | - strlcpy(info->version, DRV_MODULE_VERSION, sizeof(info->version)); |
|---|
| 240 | 222 | } |
|---|
| 241 | 223 | |
|---|
| 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) |
|---|
| 244 | 226 | { |
|---|
| 245 | 227 | struct bnxt_vf_rep *vf_rep = netdev_priv(dev); |
|---|
| 246 | 228 | |
|---|
| 247 | 229 | /* as only PORT_PARENT_ID is supported currently use common code |
|---|
| 248 | 230 | * between PF and VF-rep for now. |
|---|
| 249 | 231 | */ |
|---|
| 250 | | - return bnxt_port_attr_get(vf_rep->bp, attr); |
|---|
| 232 | + return bnxt_get_port_parent_id(vf_rep->bp->dev, ppid); |
|---|
| 251 | 233 | } |
|---|
| 252 | | - |
|---|
| 253 | | -static const struct switchdev_ops bnxt_vf_rep_switchdev_ops = { |
|---|
| 254 | | - .switchdev_port_attr_get = bnxt_vf_rep_port_attr_get |
|---|
| 255 | | -}; |
|---|
| 256 | 234 | |
|---|
| 257 | 235 | static const struct ethtool_ops bnxt_vf_rep_ethtool_ops = { |
|---|
| 258 | 236 | .get_drvinfo = bnxt_vf_rep_get_drvinfo |
|---|
| .. | .. |
|---|
| 264 | 242 | .ndo_start_xmit = bnxt_vf_rep_xmit, |
|---|
| 265 | 243 | .ndo_get_stats64 = bnxt_vf_rep_get_stats64, |
|---|
| 266 | 244 | .ndo_setup_tc = bnxt_vf_rep_setup_tc, |
|---|
| 245 | + .ndo_get_port_parent_id = bnxt_vf_rep_get_port_parent_id, |
|---|
| 267 | 246 | .ndo_get_phys_port_name = bnxt_vf_rep_get_phys_port_name |
|---|
| 268 | 247 | }; |
|---|
| 269 | 248 | |
|---|
| .. | .. |
|---|
| 394 | 373 | |
|---|
| 395 | 374 | dev->netdev_ops = &bnxt_vf_rep_netdev_ops; |
|---|
| 396 | 375 | dev->ethtool_ops = &bnxt_vf_rep_ethtool_ops; |
|---|
| 397 | | - SWITCHDEV_SET_OPS(dev, &bnxt_vf_rep_switchdev_ops); |
|---|
| 398 | 376 | /* Just inherit all the featues of the parent PF as the VF-R |
|---|
| 399 | 377 | * uses the RX/TX rings of the parent PF |
|---|
| 400 | 378 | */ |
|---|
| .. | .. |
|---|
| 412 | 390 | dev->min_mtu = ETH_ZLEN; |
|---|
| 413 | 391 | } |
|---|
| 414 | 392 | |
|---|
| 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 | | - |
|---|
| 435 | 393 | static int bnxt_vf_reps_create(struct bnxt *bp) |
|---|
| 436 | 394 | { |
|---|
| 437 | 395 | u16 *cfa_code_map = NULL, num_vfs = pci_num_vf(bp->pdev); |
|---|
| 438 | 396 | struct bnxt_vf_rep *vf_rep; |
|---|
| 439 | 397 | struct net_device *dev; |
|---|
| 440 | 398 | int rc, i; |
|---|
| 399 | + |
|---|
| 400 | + if (!(bp->flags & BNXT_FLAG_DSN_VALID)) |
|---|
| 401 | + return -ENODEV; |
|---|
| 441 | 402 | |
|---|
| 442 | 403 | bp->vf_reps = kcalloc(num_vfs, sizeof(vf_rep), GFP_KERNEL); |
|---|
| 443 | 404 | if (!bp->vf_reps) |
|---|
| .. | .. |
|---|
| 496 | 457 | } |
|---|
| 497 | 458 | } |
|---|
| 498 | 459 | |
|---|
| 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 | | - |
|---|
| 504 | 460 | /* publish cfa_code_map only after all VF-reps have been initialized */ |
|---|
| 505 | 461 | bp->cfa_code_map = cfa_code_map; |
|---|
| 506 | 462 | bp->eswitch_mode = DEVLINK_ESWITCH_MODE_SWITCHDEV; |
|---|
| .. | .. |
|---|
| 508 | 464 | return 0; |
|---|
| 509 | 465 | |
|---|
| 510 | 466 | err: |
|---|
| 511 | | - netdev_info(bp->dev, "%s error=%d", __func__, rc); |
|---|
| 467 | + netdev_info(bp->dev, "%s error=%d\n", __func__, rc); |
|---|
| 512 | 468 | kfree(cfa_code_map); |
|---|
| 513 | 469 | __bnxt_vf_reps_destroy(bp); |
|---|
| 514 | 470 | return rc; |
|---|
| .. | .. |
|---|
| 523 | 479 | return 0; |
|---|
| 524 | 480 | } |
|---|
| 525 | 481 | |
|---|
| 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) |
|---|
| 527 | 484 | { |
|---|
| 528 | 485 | struct bnxt *bp = bnxt_get_bp_from_dl(devlink); |
|---|
| 529 | 486 | int rc = 0; |
|---|
| 530 | 487 | |
|---|
| 531 | 488 | mutex_lock(&bp->sriov_lock); |
|---|
| 532 | 489 | 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", |
|---|
| 534 | 491 | mode == DEVLINK_ESWITCH_MODE_LEGACY ? |
|---|
| 535 | 492 | "legacy" : "switchdev"); |
|---|
| 536 | 493 | rc = -EINVAL; |
|---|
| .. | .. |
|---|
| 550 | 507 | } |
|---|
| 551 | 508 | |
|---|
| 552 | 509 | 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"); |
|---|
| 554 | 511 | rc = -EPERM; |
|---|
| 555 | 512 | goto done; |
|---|
| 556 | 513 | } |
|---|