]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
net/mlx5_core: Add helper function to read virtual port counters
authorMeny Yossefi <menyy@mellanox.com>
Thu, 18 Feb 2016 16:14:59 +0000 (18:14 +0200)
committerDoug Ledford <dledford@redhat.com>
Tue, 1 Mar 2016 15:57:15 +0000 (10:57 -0500)
Added helper function to read 64bit virtual port Infiniband traffic
counters.

Signed-off-by: Meny Yossefi <menyy@mellanox.com>
Signed-off-by: Majd Dibbiny <majd@mellanox.com>
Reviewed-by: Matan Barak <matanb@mellanox.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/net/ethernet/mellanox/mlx5/core/vport.c
include/linux/mlx5/mlx5_ifc.h
include/linux/mlx5/vport.h

index c7398b95aecdc0286480f85564e5a42660275bd6..90ab09e375b8dff7c957fbdd8eee3dd46429273e 100644 (file)
@@ -850,3 +850,43 @@ int mlx5_nic_vport_disable_roce(struct mlx5_core_dev *mdev)
        return mlx5_nic_vport_update_roce_state(mdev, MLX5_VPORT_ROCE_DISABLED);
 }
 EXPORT_SYMBOL_GPL(mlx5_nic_vport_disable_roce);
+
+int mlx5_core_query_vport_counter(struct mlx5_core_dev *dev, u8 other_vport,
+                                 u8 port_num, void *out, size_t out_sz)
+{
+       int     in_sz = MLX5_ST_SZ_BYTES(query_vport_counter_in);
+       int     is_group_manager;
+       void   *in;
+       int     err;
+
+       is_group_manager = MLX5_CAP_GEN(dev, vport_group_manager);
+       in = mlx5_vzalloc(in_sz);
+       if (!in) {
+               err = -ENOMEM;
+               return err;
+       }
+
+       MLX5_SET(query_vport_counter_in, in, opcode,
+                MLX5_CMD_OP_QUERY_VPORT_COUNTER);
+       if (other_vport) {
+               if (is_group_manager) {
+                       MLX5_SET(query_vport_counter_in, in, other_vport, 1);
+                       MLX5_SET(query_vport_counter_in, in, vport_number, 0);
+               } else {
+                       err = -EPERM;
+                       goto free;
+               }
+       }
+       if (MLX5_CAP_GEN(dev, num_ports) == 2)
+               MLX5_SET(query_vport_counter_in, in, port_num, port_num);
+
+       err = mlx5_cmd_exec(dev, in, in_sz, out,  out_sz);
+       if (err)
+               goto free;
+       err = mlx5_cmd_status_to_err_v2(out);
+
+free:
+       kvfree(in);
+       return err;
+}
+EXPORT_SYMBOL_GPL(mlx5_core_query_vport_counter);
index 51f1e540fc2b83bf9dd143637bad8acdbc44d0fd..0732e6c1fe7a43dad2e7a1af1e3c046408f36d7d 100644 (file)
@@ -3126,7 +3126,8 @@ struct mlx5_ifc_query_vport_counter_in_bits {
        u8         op_mod[0x10];
 
        u8         other_vport[0x1];
-       u8         reserved_at_41[0xf];
+       u8         reserved_at_41[0xb];
+       u8         port_num[0x4];
        u8         vport_number[0x10];
 
        u8         reserved_at_60[0x60];
index 123771003e68586571690f9a5211e5afaa0143e3..a9f2bcc98cabff2f29c90735b3e9d5452ded4520 100644 (file)
@@ -92,5 +92,7 @@ int mlx5_modify_nic_vport_vlans(struct mlx5_core_dev *dev,
 
 int mlx5_nic_vport_enable_roce(struct mlx5_core_dev *mdev);
 int mlx5_nic_vport_disable_roce(struct mlx5_core_dev *mdev);
+int mlx5_core_query_vport_counter(struct mlx5_core_dev *dev, u8 other_vport,
+                                 u8 port_num, void *out, size_t out_sz);
 
 #endif /* __MLX5_VPORT_H__ */