| 413 | } |
| 414 | |
| 415 | int |
| 416 | sfc_port_attach(struct sfc_adapter *sa) |
| 417 | { |
| 418 | struct sfc_port *port = &sa->port; |
| 419 | const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic); |
| 420 | const struct rte_ether_addr *from; |
| 421 | uint32_t mac_nstats; |
| 422 | size_t mac_stats_size; |
| 423 | long kvarg_stats_update_period_ms; |
| 424 | int rc; |
| 425 | |
| 426 | sfc_log_init(sa, "entry"); |
| 427 | |
| 428 | efx_phy_adv_cap_get(sa->nic, EFX_PHY_CAP_PERM, &port->phy_adv_cap_mask); |
| 429 | |
| 430 | /* Enable flow control by default */ |
| 431 | port->flow_ctrl = EFX_FCNTL_RESPOND | EFX_FCNTL_GENERATE; |
| 432 | port->flow_ctrl_autoneg = B_TRUE; |
| 433 | |
| 434 | RTE_BUILD_BUG_ON(sizeof(encp->enc_mac_addr) != sizeof(*from)); |
| 435 | from = (const struct rte_ether_addr *)(encp->enc_mac_addr); |
| 436 | rte_ether_addr_copy(from, &port->default_mac_addr); |
| 437 | |
| 438 | port->max_mcast_addrs = EFX_MAC_MULTICAST_LIST_MAX; |
| 439 | port->nb_mcast_addrs = 0; |
| 440 | port->mcast_addrs = rte_calloc_socket("mcast_addr_list_buf", |
| 441 | port->max_mcast_addrs, |
| 442 | EFX_MAC_ADDR_LEN, 0, |
| 443 | sa->socket_id); |
| 444 | if (port->mcast_addrs == NULL) { |
| 445 | rc = ENOMEM; |
| 446 | goto fail_mcast_addr_list_buf_alloc; |
| 447 | } |
| 448 | |
| 449 | rc = ENOMEM; |
| 450 | port->mac_stats_buf = rte_calloc_socket("mac_stats_buf", EFX_MAC_NSTATS, |
| 451 | sizeof(uint64_t), 0, |
| 452 | sa->socket_id); |
| 453 | if (port->mac_stats_buf == NULL) |
| 454 | goto fail_mac_stats_buf_alloc; |
| 455 | |
| 456 | mac_nstats = efx_nic_cfg_get(sa->nic)->enc_mac_stats_nstats; |
| 457 | mac_stats_size = RTE_ALIGN(mac_nstats * sizeof(uint64_t), EFX_BUF_SIZE); |
| 458 | rc = sfc_dma_alloc(sa, "mac_stats", 0, EFX_NIC_DMA_ADDR_MAC_STATS_BUF, |
| 459 | mac_stats_size, |
| 460 | sa->socket_id, &port->mac_stats_dma_mem); |
| 461 | if (rc != 0) |
| 462 | goto fail_mac_stats_dma_alloc; |
| 463 | |
| 464 | port->mac_stats_reset_pending = B_FALSE; |
| 465 | |
| 466 | kvarg_stats_update_period_ms = SFC_MAC_STATS_UPDATE_PERIOD_MS_DEF; |
| 467 | |
| 468 | rc = sfc_kvargs_process(sa, SFC_KVARG_STATS_UPDATE_PERIOD_MS, |
| 469 | sfc_kvarg_long_handler, |
| 470 | &kvarg_stats_update_period_ms); |
| 471 | if ((rc == 0) && |
| 472 | ((kvarg_stats_update_period_ms < 0) || |
no test coverage detected