Comment 41 for bug 1771662

Revision history for this message
Paolo Pisati (p-pisati) wrote :

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/
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c: .ndo_get_phys_port_id = cxgb4_mgmt_get_phys_port_id,
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c: .ndo_get_phys_port_id = bnx2x_get_phys_port_id,
drivers/net/ethernet/mellanox/mlx4/en_netdev.c: .ndo_get_phys_port_id = mlx4_en_get_phys_port_id,
drivers/net/ethernet/mellanox/mlx4/en_netdev.c: .ndo_get_phys_port_id = mlx4_en_get_phys_port_id,
drivers/net/ethernet/sfc/efx.c: .ndo_get_phys_port_id = efx_get_phys_port_id,
drivers/net/ethernet/emulex/benet/be_main.c: .ndo_get_phys_port_id = be_get_phys_port_id,
drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c: .ndo_get_phys_port_id = qlcnic_get_phys_port_id,
drivers/net/ethernet/intel/i40e/i40e_main.c: .ndo_get_phys_port_id = i40e_get_phys_port_id,

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);