aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/mellanox/mlx4/mcg.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/ethernet/mellanox/mlx4/mcg.c')
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/mcg.c106
1 files changed, 15 insertions, 91 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx4/mcg.c b/drivers/net/ethernet/mellanox/mlx4/mcg.c
index a018ea2a43de..e151c21baf2b 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mcg.c
+++ b/drivers/net/ethernet/mellanox/mlx4/mcg.c
@@ -137,11 +137,11 @@ static int mlx4_GID_HASH(struct mlx4_dev *dev, struct mlx4_cmd_mailbox *mailbox,
137 return err; 137 return err;
138} 138}
139 139
140static struct mlx4_promisc_qp *get_promisc_qp(struct mlx4_dev *dev, u8 pf_num, 140static struct mlx4_promisc_qp *get_promisc_qp(struct mlx4_dev *dev, u8 port,
141 enum mlx4_steer_type steer, 141 enum mlx4_steer_type steer,
142 u32 qpn) 142 u32 qpn)
143{ 143{
144 struct mlx4_steer *s_steer = &mlx4_priv(dev)->steer[pf_num]; 144 struct mlx4_steer *s_steer = &mlx4_priv(dev)->steer[port - 1];
145 struct mlx4_promisc_qp *pqp; 145 struct mlx4_promisc_qp *pqp;
146 146
147 list_for_each_entry(pqp, &s_steer->promisc_qps[steer], list) { 147 list_for_each_entry(pqp, &s_steer->promisc_qps[steer], list) {
@@ -182,7 +182,7 @@ static int new_steering_entry(struct mlx4_dev *dev, u8 port,
182 /* If the given qpn is also a promisc qp, 182 /* If the given qpn is also a promisc qp,
183 * it should be inserted to duplicates list 183 * it should be inserted to duplicates list
184 */ 184 */
185 pqp = get_promisc_qp(dev, 0, steer, qpn); 185 pqp = get_promisc_qp(dev, port, steer, qpn);
186 if (pqp) { 186 if (pqp) {
187 dqp = kmalloc(sizeof *dqp, GFP_KERNEL); 187 dqp = kmalloc(sizeof *dqp, GFP_KERNEL);
188 if (!dqp) { 188 if (!dqp) {
@@ -256,7 +256,7 @@ static int existing_steering_entry(struct mlx4_dev *dev, u8 port,
256 256
257 s_steer = &mlx4_priv(dev)->steer[port - 1]; 257 s_steer = &mlx4_priv(dev)->steer[port - 1];
258 258
259 pqp = get_promisc_qp(dev, 0, steer, qpn); 259 pqp = get_promisc_qp(dev, port, steer, qpn);
260 if (!pqp) 260 if (!pqp)
261 return 0; /* nothing to do */ 261 return 0; /* nothing to do */
262 262
@@ -302,7 +302,7 @@ static bool check_duplicate_entry(struct mlx4_dev *dev, u8 port,
302 s_steer = &mlx4_priv(dev)->steer[port - 1]; 302 s_steer = &mlx4_priv(dev)->steer[port - 1];
303 303
304 /* if qp is not promisc, it cannot be duplicated */ 304 /* if qp is not promisc, it cannot be duplicated */
305 if (!get_promisc_qp(dev, 0, steer, qpn)) 305 if (!get_promisc_qp(dev, port, steer, qpn))
306 return false; 306 return false;
307 307
308 /* The qp is promisc qp so it is a duplicate on this index 308 /* The qp is promisc qp so it is a duplicate on this index
@@ -352,7 +352,7 @@ static bool can_remove_steering_entry(struct mlx4_dev *dev, u8 port,
352 members_count = be32_to_cpu(mgm->members_count) & 0xffffff; 352 members_count = be32_to_cpu(mgm->members_count) & 0xffffff;
353 for (i = 0; i < members_count; i++) { 353 for (i = 0; i < members_count; i++) {
354 qpn = be32_to_cpu(mgm->qp[i]) & MGM_QPN_MASK; 354 qpn = be32_to_cpu(mgm->qp[i]) & MGM_QPN_MASK;
355 if (!get_promisc_qp(dev, 0, steer, qpn) && qpn != tqpn) { 355 if (!get_promisc_qp(dev, port, steer, qpn) && qpn != tqpn) {
356 /* the qp is not promisc, the entry can't be removed */ 356 /* the qp is not promisc, the entry can't be removed */
357 goto out; 357 goto out;
358 } 358 }
@@ -398,7 +398,7 @@ static int add_promisc_qp(struct mlx4_dev *dev, u8 port,
398 398
399 mutex_lock(&priv->mcg_table.mutex); 399 mutex_lock(&priv->mcg_table.mutex);
400 400
401 if (get_promisc_qp(dev, 0, steer, qpn)) { 401 if (get_promisc_qp(dev, port, steer, qpn)) {
402 err = 0; /* Noting to do, already exists */ 402 err = 0; /* Noting to do, already exists */
403 goto out_mutex; 403 goto out_mutex;
404 } 404 }
@@ -503,7 +503,7 @@ static int remove_promisc_qp(struct mlx4_dev *dev, u8 port,
503 s_steer = &mlx4_priv(dev)->steer[port - 1]; 503 s_steer = &mlx4_priv(dev)->steer[port - 1];
504 mutex_lock(&priv->mcg_table.mutex); 504 mutex_lock(&priv->mcg_table.mutex);
505 505
506 pqp = get_promisc_qp(dev, 0, steer, qpn); 506 pqp = get_promisc_qp(dev, port, steer, qpn);
507 if (unlikely(!pqp)) { 507 if (unlikely(!pqp)) {
508 mlx4_warn(dev, "QP %x is not promiscuous QP\n", qpn); 508 mlx4_warn(dev, "QP %x is not promiscuous QP\n", qpn);
509 /* nothing to do */ 509 /* nothing to do */
@@ -650,13 +650,6 @@ static int find_entry(struct mlx4_dev *dev, u8 port,
650 return err; 650 return err;
651} 651}
652 652
653struct mlx4_net_trans_rule_hw_ctrl {
654 __be32 ctrl;
655 __be32 vf_vep_port;
656 __be32 qpn;
657 __be32 reserved;
658};
659
660static void trans_rule_ctrl_to_hw(struct mlx4_net_trans_rule *ctrl, 653static void trans_rule_ctrl_to_hw(struct mlx4_net_trans_rule *ctrl,
661 struct mlx4_net_trans_rule_hw_ctrl *hw) 654 struct mlx4_net_trans_rule_hw_ctrl *hw)
662{ 655{
@@ -680,87 +673,18 @@ static void trans_rule_ctrl_to_hw(struct mlx4_net_trans_rule *ctrl,
680 hw->qpn = cpu_to_be32(ctrl->qpn); 673 hw->qpn = cpu_to_be32(ctrl->qpn);
681} 674}
682 675
683struct mlx4_net_trans_rule_hw_ib { 676const u16 __sw_id_hw[] = {
684 u8 size; 677 [MLX4_NET_TRANS_RULE_ID_ETH] = 0xE001,
685 u8 rsvd1; 678 [MLX4_NET_TRANS_RULE_ID_IB] = 0xE005,
686 __be16 id; 679 [MLX4_NET_TRANS_RULE_ID_IPV6] = 0xE003,
687 u32 rsvd2; 680 [MLX4_NET_TRANS_RULE_ID_IPV4] = 0xE002,
688 __be32 qpn; 681 [MLX4_NET_TRANS_RULE_ID_TCP] = 0xE004,
689 __be32 qpn_mask; 682 [MLX4_NET_TRANS_RULE_ID_UDP] = 0xE006
690 u8 dst_gid[16];
691 u8 dst_gid_msk[16];
692} __packed;
693
694struct mlx4_net_trans_rule_hw_eth {
695 u8 size;
696 u8 rsvd;
697 __be16 id;
698 u8 rsvd1[6];
699 u8 dst_mac[6];
700 u16 rsvd2;
701 u8 dst_mac_msk[6];
702 u16 rsvd3;
703 u8 src_mac[6];
704 u16 rsvd4;
705 u8 src_mac_msk[6];
706 u8 rsvd5;
707 u8 ether_type_enable;
708 __be16 ether_type;
709 __be16 vlan_id_msk;
710 __be16 vlan_id;
711} __packed;
712
713struct mlx4_net_trans_rule_hw_tcp_udp {
714 u8 size;
715 u8 rsvd;
716 __be16 id;
717 __be16 rsvd1[3];
718 __be16 dst_port;
719 __be16 rsvd2;
720 __be16 dst_port_msk;
721 __be16 rsvd3;
722 __be16 src_port;
723 __be16 rsvd4;
724 __be16 src_port_msk;
725} __packed;
726
727struct mlx4_net_trans_rule_hw_ipv4 {
728 u8 size;
729 u8 rsvd;
730 __be16 id;
731 __be32 rsvd1;
732 __be32 dst_ip;
733 __be32 dst_ip_msk;
734 __be32 src_ip;
735 __be32 src_ip_msk;
736} __packed;
737
738struct _rule_hw {
739 union {
740 struct {
741 u8 size;
742 u8 rsvd;
743 __be16 id;
744 };
745 struct mlx4_net_trans_rule_hw_eth eth;
746 struct mlx4_net_trans_rule_hw_ib ib;
747 struct mlx4_net_trans_rule_hw_ipv4 ipv4;
748 struct mlx4_net_trans_rule_hw_tcp_udp tcp_udp;
749 };
750}; 683};
751 684
752static int parse_trans_rule(struct mlx4_dev *dev, struct mlx4_spec_list *spec, 685static int parse_trans_rule(struct mlx4_dev *dev, struct mlx4_spec_list *spec,
753 struct _rule_hw *rule_hw) 686 struct _rule_hw *rule_hw)
754{ 687{
755 static const u16 __sw_id_hw[] = {
756 [MLX4_NET_TRANS_RULE_ID_ETH] = 0xE001,
757 [MLX4_NET_TRANS_RULE_ID_IB] = 0xE005,
758 [MLX4_NET_TRANS_RULE_ID_IPV6] = 0xE003,
759 [MLX4_NET_TRANS_RULE_ID_IPV4] = 0xE002,
760 [MLX4_NET_TRANS_RULE_ID_TCP] = 0xE004,
761 [MLX4_NET_TRANS_RULE_ID_UDP] = 0xE006
762 };
763
764 static const size_t __rule_hw_sz[] = { 688 static const size_t __rule_hw_sz[] = {
765 [MLX4_NET_TRANS_RULE_ID_ETH] = 689 [MLX4_NET_TRANS_RULE_ID_ETH] =
766 sizeof(struct mlx4_net_trans_rule_hw_eth), 690 sizeof(struct mlx4_net_trans_rule_hw_eth),