Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sfc: Add sysfs entry for flags (link control and primary)

On every adapter there will be one primary PF per adaptor and
one link control PF per port.

Signed-off-by: Shradha Shah <sshah@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Shradha Shah and committed by
David S. Miller
0f5c0845 c9012e00

+51 -7
+51 -7
drivers/net/ethernet/sfc/ef10.c
··· 246 246 return 0; 247 247 } 248 248 249 + static ssize_t efx_ef10_show_link_control_flag(struct device *dev, 250 + struct device_attribute *attr, 251 + char *buf) 252 + { 253 + struct efx_nic *efx = pci_get_drvdata(to_pci_dev(dev)); 254 + 255 + return sprintf(buf, "%d\n", 256 + ((efx->mcdi->fn_flags) & 257 + (1 << MC_CMD_DRV_ATTACH_EXT_OUT_FLAG_LINKCTRL)) 258 + ? 1 : 0); 259 + } 260 + 261 + static ssize_t efx_ef10_show_primary_flag(struct device *dev, 262 + struct device_attribute *attr, 263 + char *buf) 264 + { 265 + struct efx_nic *efx = pci_get_drvdata(to_pci_dev(dev)); 266 + 267 + return sprintf(buf, "%d\n", 268 + ((efx->mcdi->fn_flags) & 269 + (1 << MC_CMD_DRV_ATTACH_EXT_OUT_FLAG_PRIMARY)) 270 + ? 1 : 0); 271 + } 272 + 273 + static DEVICE_ATTR(link_control_flag, 0444, efx_ef10_show_link_control_flag, 274 + NULL); 275 + static DEVICE_ATTR(primary_flag, 0444, efx_ef10_show_primary_flag, NULL); 276 + 249 277 static int efx_ef10_probe(struct efx_nic *efx) 250 278 { 251 279 struct efx_ef10_nic_data *nic_data; ··· 343 315 if (rc) 344 316 goto fail3; 345 317 346 - rc = efx_ef10_get_pf_index(efx); 318 + rc = device_create_file(&efx->pci_dev->dev, 319 + &dev_attr_link_control_flag); 347 320 if (rc) 348 321 goto fail3; 349 322 323 + rc = device_create_file(&efx->pci_dev->dev, &dev_attr_primary_flag); 324 + if (rc) 325 + goto fail4; 326 + 327 + rc = efx_ef10_get_pf_index(efx); 328 + if (rc) 329 + goto fail5; 330 + 350 331 rc = efx_ef10_init_datapath_caps(efx); 351 332 if (rc < 0) 352 - goto fail3; 333 + goto fail5; 353 334 354 335 efx->rx_packet_len_offset = 355 336 ES_DZ_RX_PREFIX_PKTLEN_OFST - ES_DZ_RX_PREFIX_SIZE; 356 337 357 338 rc = efx_mcdi_port_get_number(efx); 358 339 if (rc < 0) 359 - goto fail3; 340 + goto fail5; 360 341 efx->port_num = rc; 361 342 net_dev->dev_port = rc; 362 343 363 344 rc = efx->type->get_mac_address(efx, efx->net_dev->perm_addr); 364 345 if (rc) 365 - goto fail3; 346 + goto fail5; 366 347 367 348 rc = efx_ef10_get_sysclk_freq(efx); 368 349 if (rc < 0) 369 - goto fail3; 350 + goto fail5; 370 351 efx->timer_quantum_ns = 1536000 / rc; /* 1536 cycles */ 371 352 372 353 /* Check whether firmware supports bug 35388 workaround. ··· 394 357 nic_data->workaround_35388 = enabled & 395 358 MC_CMD_GET_WORKAROUNDS_OUT_BUG35388; 396 359 } else if (rc != -ENOSYS && rc != -ENOENT) { 397 - goto fail3; 360 + goto fail5; 398 361 } 399 362 netif_dbg(efx, probe, efx->net_dev, 400 363 "workaround for bug 35388 is %sabled\n", ··· 402 365 403 366 rc = efx_mcdi_mon_probe(efx); 404 367 if (rc && rc != -EPERM) 405 - goto fail3; 368 + goto fail5; 406 369 407 370 efx_ptp_probe(efx, NULL); 408 371 409 372 return 0; 410 373 374 + fail5: 375 + device_remove_file(&efx->pci_dev->dev, &dev_attr_primary_flag); 376 + fail4: 377 + device_remove_file(&efx->pci_dev->dev, &dev_attr_link_control_flag); 411 378 fail3: 412 379 efx_mcdi_fini(efx); 413 380 fail2: ··· 653 612 654 613 if (!nic_data->must_restore_piobufs) 655 614 efx_ef10_free_piobufs(efx); 615 + 616 + device_remove_file(&efx->pci_dev->dev, &dev_attr_primary_flag); 617 + device_remove_file(&efx->pci_dev->dev, &dev_attr_link_control_flag); 656 618 657 619 efx_mcdi_fini(efx); 658 620 efx_nic_free_buffer(efx, &nic_data->mcdi_buf);