]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mlx4_core: allow unprivileged VFs read physical port counters
authorMukesh Kacker <mukesh.kacker@oracle.com>
Sat, 19 Dec 2015 04:15:58 +0000 (20:15 -0800)
committerChuck Anderson <chuck.anderson@oracle.com>
Tue, 13 Sep 2016 05:54:43 +0000 (22:54 -0700)
For compatibility to Guest OS running older release, we allow
VFs to read physical port counters

Orabug: 24656803

Signed-off-by: Mukesh Kacker <mukesh.kacker@oracle.com>
Reviewed-by: Santosh Shilimkar<santosh.shilimkar@oracle.com>
drivers/net/ethernet/mellanox/mlx4/cmd.c

index ca4668684ef15ea627453c1d0b895e98b342653f..3a48571f8afc03297457f0841169fecbf69ff69f 100644 (file)
@@ -42,6 +42,7 @@
 #include <linux/mlx4/device.h>
 #include <linux/semaphore.h>
 #include <rdma/ib_smi.h>
+#include <rdma/ib_pma.h>
 #include <linux/delay.h>
 
 #include <asm/io.h>
@@ -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,