diff options
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx4/en_port.h | 2 | ||||
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx4/mlx4.h | 20 | ||||
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx4/port.c | 62 | ||||
-rw-r--r-- | include/linux/mlx4/cmd.h | 4 | ||||
-rw-r--r-- | include/linux/mlx4/device.h | 3 |
5 files changed, 91 insertions, 0 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_port.h b/drivers/net/ethernet/mellanox/mlx4/en_port.h index 6934fd7e66ed..745090b49d9e 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_port.h +++ b/drivers/net/ethernet/mellanox/mlx4/en_port.h | |||
@@ -39,6 +39,8 @@ | |||
39 | #define SET_PORT_PROMISC_SHIFT 31 | 39 | #define SET_PORT_PROMISC_SHIFT 31 |
40 | #define SET_PORT_MC_PROMISC_SHIFT 30 | 40 | #define SET_PORT_MC_PROMISC_SHIFT 30 |
41 | 41 | ||
42 | #define MLX4_EN_NUM_TC 8 | ||
43 | |||
42 | #define VLAN_FLTR_SIZE 128 | 44 | #define VLAN_FLTR_SIZE 128 |
43 | struct mlx4_set_vlan_fltr_mbox { | 45 | struct mlx4_set_vlan_fltr_mbox { |
44 | __be32 entry[VLAN_FLTR_SIZE]; | 46 | __be32 entry[VLAN_FLTR_SIZE]; |
diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4.h b/drivers/net/ethernet/mellanox/mlx4/mlx4.h index 2a0ff2cc7182..cd56f1aea4b5 100644 --- a/drivers/net/ethernet/mellanox/mlx4/mlx4.h +++ b/drivers/net/ethernet/mellanox/mlx4/mlx4.h | |||
@@ -53,6 +53,26 @@ | |||
53 | #define DRV_VERSION "1.1" | 53 | #define DRV_VERSION "1.1" |
54 | #define DRV_RELDATE "Dec, 2011" | 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 | enum { | 76 | enum { |
57 | MLX4_HCR_BASE = 0x80680, | 77 | MLX4_HCR_BASE = 0x80680, |
58 | MLX4_HCR_SIZE = 0x0001c, | 78 | MLX4_HCR_SIZE = 0x0001c, |
diff --git a/drivers/net/ethernet/mellanox/mlx4/port.c b/drivers/net/ethernet/mellanox/mlx4/port.c index 77535ff18f1b..55b12e6bed87 100644 --- a/drivers/net/ethernet/mellanox/mlx4/port.c +++ b/drivers/net/ethernet/mellanox/mlx4/port.c | |||
@@ -834,6 +834,68 @@ int mlx4_SET_PORT_qpn_calc(struct mlx4_dev *dev, u8 port, u32 base_qpn, | |||
834 | } | 834 | } |
835 | EXPORT_SYMBOL(mlx4_SET_PORT_qpn_calc); | 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 | int mlx4_SET_MCAST_FLTR_wrapper(struct mlx4_dev *dev, int slave, | 899 | int mlx4_SET_MCAST_FLTR_wrapper(struct mlx4_dev *dev, int slave, |
838 | struct mlx4_vhcr *vhcr, | 900 | struct mlx4_vhcr *vhcr, |
839 | struct mlx4_cmd_mailbox *inbox, | 901 | struct mlx4_cmd_mailbox *inbox, |
diff --git a/include/linux/mlx4/cmd.h b/include/linux/mlx4/cmd.h index 9958ff2cad3c..1f3860a8a109 100644 --- a/include/linux/mlx4/cmd.h +++ b/include/linux/mlx4/cmd.h | |||
@@ -150,6 +150,10 @@ enum { | |||
150 | /* statistics commands */ | 150 | /* statistics commands */ |
151 | MLX4_CMD_QUERY_IF_STAT = 0X54, | 151 | MLX4_CMD_QUERY_IF_STAT = 0X54, |
152 | MLX4_CMD_SET_IF_STAT = 0X55, | 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 | enum { | 159 | enum { |
diff --git a/include/linux/mlx4/device.h b/include/linux/mlx4/device.h index 834c96c5d879..6d028247f79d 100644 --- a/include/linux/mlx4/device.h +++ b/include/linux/mlx4/device.h | |||
@@ -628,6 +628,9 @@ int mlx4_SET_PORT_general(struct mlx4_dev *dev, u8 port, int mtu, | |||
628 | u8 pptx, u8 pfctx, u8 pprx, u8 pfcrx); | 628 | u8 pptx, u8 pfctx, u8 pprx, u8 pfcrx); |
629 | int mlx4_SET_PORT_qpn_calc(struct mlx4_dev *dev, u8 port, u32 base_qpn, | 629 | int mlx4_SET_PORT_qpn_calc(struct mlx4_dev *dev, u8 port, u32 base_qpn, |
630 | u8 promisc); | 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 | int mlx4_find_cached_vlan(struct mlx4_dev *dev, u8 port, u16 vid, int *idx); | 634 | int mlx4_find_cached_vlan(struct mlx4_dev *dev, u8 port, u16 vid, int *idx); |
632 | int mlx4_register_vlan(struct mlx4_dev *dev, u8 port, u16 vlan, int *index); | 635 | int mlx4_register_vlan(struct mlx4_dev *dev, u8 port, u16 vlan, int *index); |
633 | void mlx4_unregister_vlan(struct mlx4_dev *dev, u8 port, int index); | 636 | void mlx4_unregister_vlan(struct mlx4_dev *dev, u8 port, int index); |