Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net/mlx4_core: set port QoS attributes

Adding QoS firmware commands:
- mlx4_en_SET_PORT_PRIO2TC - set UP <=> TC
- mlx4_en_SET_PORT_SCHEDULER - set promised BW, max BW and PG number

Signed-off-by: Amir Vadai <amirv@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Amir Vadai and committed by
David S. Miller
e5395e92 0e98b523

+91
+2
drivers/net/ethernet/mellanox/mlx4/en_port.h
··· 39 39 #define SET_PORT_PROMISC_SHIFT 31 40 40 #define SET_PORT_MC_PROMISC_SHIFT 30 41 41 42 + #define MLX4_EN_NUM_TC 8 43 + 42 44 #define VLAN_FLTR_SIZE 128 43 45 struct mlx4_set_vlan_fltr_mbox { 44 46 __be32 entry[VLAN_FLTR_SIZE];
+20
drivers/net/ethernet/mellanox/mlx4/mlx4.h
··· 53 53 #define DRV_VERSION "1.1" 54 54 #define DRV_RELDATE "Dec, 2011" 55 55 56 + #define MLX4_NUM_UP 8 57 + #define MLX4_NUM_TC 8 58 + #define MLX4_RATELIMIT_UNITS 3 /* 100 Mbps */ 59 + #define MLX4_RATELIMIT_DEFAULT 0xffff 60 + 61 + struct mlx4_set_port_prio2tc_context { 62 + u8 prio2tc[4]; 63 + }; 64 + 65 + struct mlx4_port_scheduler_tc_cfg_be { 66 + __be16 pg; 67 + __be16 bw_precentage; 68 + __be16 max_bw_units; /* 3-100Mbps, 4-1Gbps, other values - reserved */ 69 + __be16 max_bw_value; 70 + }; 71 + 72 + struct mlx4_set_port_scheduler_context { 73 + struct mlx4_port_scheduler_tc_cfg_be tc[MLX4_NUM_TC]; 74 + }; 75 + 56 76 enum { 57 77 MLX4_HCR_BASE = 0x80680, 58 78 MLX4_HCR_SIZE = 0x0001c,
+62
drivers/net/ethernet/mellanox/mlx4/port.c
··· 834 834 } 835 835 EXPORT_SYMBOL(mlx4_SET_PORT_qpn_calc); 836 836 837 + int mlx4_SET_PORT_PRIO2TC(struct mlx4_dev *dev, u8 port, u8 *prio2tc) 838 + { 839 + struct mlx4_cmd_mailbox *mailbox; 840 + struct mlx4_set_port_prio2tc_context *context; 841 + int err; 842 + u32 in_mod; 843 + int i; 844 + 845 + mailbox = mlx4_alloc_cmd_mailbox(dev); 846 + if (IS_ERR(mailbox)) 847 + return PTR_ERR(mailbox); 848 + context = mailbox->buf; 849 + memset(context, 0, sizeof *context); 850 + 851 + for (i = 0; i < MLX4_NUM_UP; i += 2) 852 + context->prio2tc[i >> 1] = prio2tc[i] << 4 | prio2tc[i + 1]; 853 + 854 + in_mod = MLX4_SET_PORT_PRIO2TC << 8 | port; 855 + err = mlx4_cmd(dev, mailbox->dma, in_mod, 1, MLX4_CMD_SET_PORT, 856 + MLX4_CMD_TIME_CLASS_B, MLX4_CMD_NATIVE); 857 + 858 + mlx4_free_cmd_mailbox(dev, mailbox); 859 + return err; 860 + } 861 + EXPORT_SYMBOL(mlx4_SET_PORT_PRIO2TC); 862 + 863 + int mlx4_SET_PORT_SCHEDULER(struct mlx4_dev *dev, u8 port, u8 *tc_tx_bw, 864 + u8 *pg, u16 *ratelimit) 865 + { 866 + struct mlx4_cmd_mailbox *mailbox; 867 + struct mlx4_set_port_scheduler_context *context; 868 + int err; 869 + u32 in_mod; 870 + int i; 871 + 872 + mailbox = mlx4_alloc_cmd_mailbox(dev); 873 + if (IS_ERR(mailbox)) 874 + return PTR_ERR(mailbox); 875 + context = mailbox->buf; 876 + memset(context, 0, sizeof *context); 877 + 878 + for (i = 0; i < MLX4_NUM_TC; i++) { 879 + struct mlx4_port_scheduler_tc_cfg_be *tc = &context->tc[i]; 880 + u16 r = ratelimit && ratelimit[i] ? ratelimit[i] : 881 + MLX4_RATELIMIT_DEFAULT; 882 + 883 + tc->pg = htons(pg[i]); 884 + tc->bw_precentage = htons(tc_tx_bw[i]); 885 + 886 + tc->max_bw_units = htons(MLX4_RATELIMIT_UNITS); 887 + tc->max_bw_value = htons(r); 888 + } 889 + 890 + in_mod = MLX4_SET_PORT_SCHEDULER << 8 | port; 891 + err = mlx4_cmd(dev, mailbox->dma, in_mod, 1, MLX4_CMD_SET_PORT, 892 + MLX4_CMD_TIME_CLASS_B, MLX4_CMD_NATIVE); 893 + 894 + mlx4_free_cmd_mailbox(dev, mailbox); 895 + return err; 896 + } 897 + EXPORT_SYMBOL(mlx4_SET_PORT_SCHEDULER); 898 + 837 899 int mlx4_SET_MCAST_FLTR_wrapper(struct mlx4_dev *dev, int slave, 838 900 struct mlx4_vhcr *vhcr, 839 901 struct mlx4_cmd_mailbox *inbox,
+4
include/linux/mlx4/cmd.h
··· 150 150 /* statistics commands */ 151 151 MLX4_CMD_QUERY_IF_STAT = 0X54, 152 152 MLX4_CMD_SET_IF_STAT = 0X55, 153 + 154 + /* set port opcode modifiers */ 155 + MLX4_SET_PORT_PRIO2TC = 0x8, 156 + MLX4_SET_PORT_SCHEDULER = 0x9, 153 157 }; 154 158 155 159 enum {
+3
include/linux/mlx4/device.h
··· 628 628 u8 pptx, u8 pfctx, u8 pprx, u8 pfcrx); 629 629 int mlx4_SET_PORT_qpn_calc(struct mlx4_dev *dev, u8 port, u32 base_qpn, 630 630 u8 promisc); 631 + int mlx4_SET_PORT_PRIO2TC(struct mlx4_dev *dev, u8 port, u8 *prio2tc); 632 + int mlx4_SET_PORT_SCHEDULER(struct mlx4_dev *dev, u8 port, u8 *tc_tx_bw, 633 + u8 *pg, u16 *ratelimit); 631 634 int mlx4_find_cached_vlan(struct mlx4_dev *dev, u8 port, u16 vid, int *idx); 632 635 int mlx4_register_vlan(struct mlx4_dev *dev, u8 port, u16 vlan, int *index); 633 636 void mlx4_unregister_vlan(struct mlx4_dev *dev, u8 port, int index);