IB/core: Add generic function to extract IB speed from netdev
Logic of retrieving netdev speed from net_device and translating it to IB speed is implemented in rxe, in usnic and in bnxt drivers. Define new function which merges all. Signed-off-by: Yuval Shaia <yuval.shaia@oracle.com> Reviewed-by: Christian Benvenuti <benve@cisco.com> Reviewed-by: Selvin Xavier <selvin.xavier@broadcom.com> Reviewed-by: Moni Shoua <monis@mellanox.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
Šī revīzija ir iekļauta:

revīziju iesūtīja
Doug Ledford

vecāks
44b0b7455f
revīzija
d41861942f
@@ -51,40 +51,16 @@ static int rxe_query_device(struct ib_device *dev,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void rxe_eth_speed_to_ib_speed(int speed, u8 *active_speed,
|
||||
u8 *active_width)
|
||||
{
|
||||
if (speed <= 1000) {
|
||||
*active_width = IB_WIDTH_1X;
|
||||
*active_speed = IB_SPEED_SDR;
|
||||
} else if (speed <= 10000) {
|
||||
*active_width = IB_WIDTH_1X;
|
||||
*active_speed = IB_SPEED_FDR10;
|
||||
} else if (speed <= 20000) {
|
||||
*active_width = IB_WIDTH_4X;
|
||||
*active_speed = IB_SPEED_DDR;
|
||||
} else if (speed <= 30000) {
|
||||
*active_width = IB_WIDTH_4X;
|
||||
*active_speed = IB_SPEED_QDR;
|
||||
} else if (speed <= 40000) {
|
||||
*active_width = IB_WIDTH_4X;
|
||||
*active_speed = IB_SPEED_FDR10;
|
||||
} else {
|
||||
*active_width = IB_WIDTH_4X;
|
||||
*active_speed = IB_SPEED_EDR;
|
||||
}
|
||||
}
|
||||
|
||||
static int rxe_query_port(struct ib_device *dev,
|
||||
u8 port_num, struct ib_port_attr *attr)
|
||||
{
|
||||
struct rxe_dev *rxe = to_rdev(dev);
|
||||
struct rxe_port *port;
|
||||
u32 speed;
|
||||
int rc = -EINVAL;
|
||||
|
||||
if (unlikely(port_num != 1)) {
|
||||
pr_warn("invalid port_number %d\n", port_num);
|
||||
goto err1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
port = &rxe->port;
|
||||
@@ -93,29 +69,12 @@ static int rxe_query_port(struct ib_device *dev,
|
||||
*attr = port->attr;
|
||||
|
||||
mutex_lock(&rxe->usdev_lock);
|
||||
if (rxe->ndev->ethtool_ops->get_link_ksettings) {
|
||||
struct ethtool_link_ksettings ks;
|
||||
|
||||
rxe->ndev->ethtool_ops->get_link_ksettings(rxe->ndev, &ks);
|
||||
speed = ks.base.speed;
|
||||
} else if (rxe->ndev->ethtool_ops->get_settings) {
|
||||
struct ethtool_cmd cmd;
|
||||
|
||||
rxe->ndev->ethtool_ops->get_settings(rxe->ndev, &cmd);
|
||||
speed = cmd.speed;
|
||||
} else {
|
||||
pr_warn("%s speed is unknown, defaulting to 1000\n",
|
||||
rxe->ndev->name);
|
||||
speed = 1000;
|
||||
}
|
||||
rxe_eth_speed_to_ib_speed(speed, &attr->active_speed,
|
||||
&attr->active_width);
|
||||
rc = ib_get_eth_speed(dev, port_num, &attr->active_speed,
|
||||
&attr->active_width);
|
||||
mutex_unlock(&rxe->usdev_lock);
|
||||
|
||||
return 0;
|
||||
|
||||
err1:
|
||||
return -EINVAL;
|
||||
out:
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int rxe_query_gid(struct ib_device *device,
|
||||
|
Atsaukties uz šo jaunā problēmā
Block a user