Skip to content

Commit e5395e9

Browse files
amirvdavem330
authored andcommitted
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>
1 parent 0e98b52 commit e5395e9

5 files changed

Lines changed: 91 additions & 0 deletions

File tree

‎drivers/net/ethernet/mellanox/mlx4/en_port.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
#define SET_PORT_PROMISC_SHIFT 31
4040
#define SET_PORT_MC_PROMISC_SHIFT 30
4141

42+
#define MLX4_EN_NUM_TC 8
43+
4244
#define VLAN_FLTR_SIZE 128
4345
struct mlx4_set_vlan_fltr_mbox {
4446
__be32 entry[VLAN_FLTR_SIZE];

‎drivers/net/ethernet/mellanox/mlx4/mlx4.h‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,26 @@
5353
#define DRV_VERSION "1.1"
5454
#define DRV_RELDATE "Dec, 2011"
5555

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+
5676
enum {
5777
MLX4_HCR_BASE = 0x80680,
5878
MLX4_HCR_SIZE = 0x0001c,

‎drivers/net/ethernet/mellanox/mlx4/port.c‎

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,68 @@ int mlx4_SET_PORT_qpn_calc(struct mlx4_dev *dev, u8 port, u32 base_qpn,
834834
}
835835
EXPORT_SYMBOL(mlx4_SET_PORT_qpn_calc);
836836

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+
837899
int mlx4_SET_MCAST_FLTR_wrapper(struct mlx4_dev *dev, int slave,
838900
struct mlx4_vhcr *vhcr,
839901
struct mlx4_cmd_mailbox *inbox,

‎include/linux/mlx4/cmd.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@ enum {
150150
/* statistics commands */
151151
MLX4_CMD_QUERY_IF_STAT = 0X54,
152152
MLX4_CMD_SET_IF_STAT = 0X55,
153+
154+
/* set port opcode modifiers */
155+
MLX4_SET_PORT_PRIO2TC = 0x8,
156+
MLX4_SET_PORT_SCHEDULER = 0x9,
153157
};
154158

155159
enum {

‎include/linux/mlx4/device.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,9 @@ int mlx4_SET_PORT_general(struct mlx4_dev *dev, u8 port, int mtu,
628628
u8 pptx, u8 pfctx, u8 pprx, u8 pfcrx);
629629
int mlx4_SET_PORT_qpn_calc(struct mlx4_dev *dev, u8 port, u32 base_qpn,
630630
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);
631634
int mlx4_find_cached_vlan(struct mlx4_dev *dev, u8 port, u16 vid, int *idx);
632635
int mlx4_register_vlan(struct mlx4_dev *dev, u8 port, u16 vlan, int *index);
633636
void mlx4_unregister_vlan(struct mlx4_dev *dev, u8 port, int index);

0 commit comments

Comments
 (0)