Actually the -EOPNOTSUPP error is the default behaviour, unless your driver implements the .ndo_get_phys_port_id() callback, and at the moment (4.18-rc3) only 7 drivers (out of several hundreds) implement that:
or you fall back to the "default behaviour" in net/core/dev.c:
/**
* dev_get_phys_port_id - Get device physical port ID
* @dev: device
* @ppid: port ID
*
* Get device physical port ID
*/
int dev_get_phys_port_id(struct net_device *dev, struct netdev_phys_item_id *ppid)
{
const struct net_device_ops *ops = dev->netdev_ops;
if (!ops->ndo_get_phys_port_id) return -EOPNOTSUPP;
return ops->ndo_get_phys_port_id(dev, ppid);
}
EXPORT_SYMBOL(dev_get_phys_port_id);
Actually the -EOPNOTSUPP error is the default behaviour, unless your driver implements the .ndo_get_ phys_port_ id() callback, and at the moment (4.18-rc3) only 7 drivers (out of several hundreds) implement that:
linux$ grep -ri do_get_phys_port_id drivers/net/ net/ethernet/ chelsio/ cxgb4/cxgb4_ main.c: .ndo_get_ phys_port_ id = cxgb4_mgmt_ get_phys_ port_id, net/ethernet/ broadcom/ bnx2x/bnx2x_ main.c: .ndo_get_ phys_port_ id = bnx2x_get_ phys_port_ id, net/ethernet/ mellanox/ mlx4/en_ netdev. c: .ndo_get_ phys_port_ id = mlx4_en_ get_phys_ port_id, net/ethernet/ mellanox/ mlx4/en_ netdev. c: .ndo_get_ phys_port_ id = mlx4_en_ get_phys_ port_id, net/ethernet/ sfc/efx. c: .ndo_get_ phys_port_ id = efx_get_ phys_port_ id, net/ethernet/ emulex/ benet/be_ main.c: .ndo_get_ phys_port_ id = be_get_ phys_port_ id, net/ethernet/ qlogic/ qlcnic/ qlcnic_ main.c: .ndo_get_ phys_port_ id = qlcnic_ get_phys_ port_id, net/ethernet/ intel/i40e/ i40e_main. c: .ndo_get_ phys_port_ id = i40e_get_ phys_port_ id,
drivers/
drivers/
drivers/
drivers/
drivers/
drivers/
drivers/
drivers/
or you fall back to the "default behaviour" in net/core/dev.c:
/** phys_port_ id - Get device physical port ID phys_port_ id(struct net_device *dev,
struct netdev_phys_item_id *ppid)
* dev_get_
* @dev: device
* @ppid: port ID
*
* Get device physical port ID
*/
int dev_get_
{
const struct net_device_ops *ops = dev->netdev_ops;
if (!ops-> ndo_get_ phys_port_ id)
return -EOPNOTSUPP; get_phys_ port_id( dev, ppid); SYMBOL( dev_get_ phys_port_ id);
return ops->ndo_
}
EXPORT_