From: Mukesh Kacker Date: Sat, 19 Dec 2015 04:15:58 +0000 (-0800) Subject: mlx4_core: allow unprivileged VFs read physical port counters X-Git-Tag: v4.1.12-92~80^2~2 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=cc46f9daf6d6b31730cb36a8829f7f89e266917b;p=users%2Fjedix%2Flinux-maple.git mlx4_core: allow unprivileged VFs read physical port counters For compatibility to Guest OS running older release, we allow VFs to read physical port counters Orabug: 24656803 Signed-off-by: Mukesh Kacker Reviewed-by: Santosh Shilimkar --- diff --git a/drivers/net/ethernet/mellanox/mlx4/cmd.c b/drivers/net/ethernet/mellanox/mlx4/cmd.c index ca4668684ef1..3a48571f8afc 100644 --- a/drivers/net/ethernet/mellanox/mlx4/cmd.c +++ b/drivers/net/ethernet/mellanox/mlx4/cmd.c @@ -42,6 +42,7 @@ #include #include #include +#include #include #include @@ -1023,19 +1024,33 @@ static int mlx4_MAD_IFC_wrapper(struct mlx4_dev *dev, int slave, } } - /* Non-privileged VFs are only allowed "host" view LID-routed 'Get' MADs. - * These are the MADs used by ib verbs (such as ib_query_gids). + /* Non-privileged VFs are only allowed certain MADs + * for the following exception cases + * + * (a) "host" view LID-routed 'Get' MADs. + * These are the MADs used by ib verbs (such as ib_query_gid). + * (b) 'Get' MADs used for performance monitoring. + * (comaptibility for older GuestOS VFs) */ - if (slave != mlx4_master_func_num(dev) && - !mlx4_vf_smi_enabled(dev, slave, port)) { - if (!(smp->mgmt_class == IB_MGMT_CLASS_SUBN_LID_ROUTED && - smp->method == IB_MGMT_METHOD_GET) || network_view) { - mlx4_err(dev, "Unprivileged slave %d is trying to execute a Subnet MGMT MAD, class 0x%x, method 0x%x, view=%s for attr 0x%x. Rejecting\n", + if ((slave != mlx4_master_func_num(dev)) && + (!mlx4_vf_smi_enabled(dev, slave, port))) { + if ((!(smp->mgmt_class == IB_MGMT_CLASS_SUBN_LID_ROUTED && + smp->method == IB_MGMT_METHOD_GET) || network_view) && + !(smp->mgmt_class == IB_MGMT_CLASS_PERF_MGMT && + smp->method == IB_MGMT_METHOD_GET && + (smp->attr_id == IB_PMA_PORT_COUNTERS || + smp->attr_id == IB_PMA_PORT_COUNTERS_EXT))) { + mlx4_err(dev, + "Unprivileged slave %d is trying to execute a Subnet MGMT MAD, class 0x%x, method 0x%x, view=%s for attr 0x%x. Rejecting\n", slave, smp->mgmt_class, smp->method, network_view ? "Network" : "Host", be16_to_cpu(smp->attr_id)); return -EPERM; } + /* We get here when we are (a) or (b) exception + * case for unprivileged VF described above + * => fallthru and process this MAD + */ } return mlx4_cmd_box(dev, inbox->dma, outbox->dma,