diff mbox

[for-next,4/7] net/mlx4_core: Add handlning of RoCE v2 over IPV4 in attach_flow

Message ID 1451395447-5198-5-git-send-email-matanb@mellanox.com (mailing list archive)
State Superseded
Headers show

Commit Message

Matan Barak Dec. 29, 2015, 1:24 p.m. UTC
From: Maor Gottlieb <maorg@mellanox.com>

When attaching multicast for RoCE v2, we need to be able to steer
packets to the QPs. Hence, we add support for IPV4 over IB steering.

Signed-off-by: Maor Gottlieb <maorg@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx4/mcg.c | 14 ++++++++++++--
 include/linux/mlx4/device.h              |  6 ++++++
 2 files changed, 18 insertions(+), 2 deletions(-)

Comments

Or Gerlitz Dec. 29, 2015, 2:28 p.m. UTC | #1
On 12/29/2015 3:24 PM, Matan Barak wrote:
> From: Maor Gottlieb <maorg@mellanox.com>
s/handlning/handling/

>
> When attaching multicast for RoCE v2, we need to be able to steer
> packets to the QPs. Hence, we add support for IPV4 over IB steering.

not sure to follow on the change-log, can you clarify it little further...

>
> Signed-off-by: Maor Gottlieb <maorg@mellanox.com>
> ---
>   drivers/net/ethernet/mellanox/mlx4/mcg.c | 14 ++++++++++++--
>   include/linux/mlx4/device.h              |  6 ++++++
>   2 files changed, 18 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx4/mcg.c b/drivers/net/ethernet/mellanox/mlx4/mcg.c
> index 1d4e2e0..834e60e 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/mcg.c
> +++ b/drivers/net/ethernet/mellanox/mlx4/mcg.c
> @@ -858,7 +858,9 @@ static int parse_trans_rule(struct mlx4_dev *dev, struct mlx4_spec_list *spec,
>   		break;
>   
>   	case MLX4_NET_TRANS_RULE_ID_IB:
> -		rule_hw->ib.l3_qpn = spec->ib.l3_qpn;
> +		rule_hw->ib.l3_qpn = spec->ib.l3_qpn |
> +			(spec->ib.roce_type == MLX4_FLOW_SPEC_IB_ROCE_TYPE_IPV4 ?
> +			 (__force __be32)0x80 : (__force __be32)0);

maybe avoid using hard coded constants and get meaningful name for them?

>   		rule_hw->ib.qpn_mask = spec->ib.qpn_msk;
>   		memcpy(&rule_hw->ib.dst_gid, &spec->ib.dst_gid, 16);
>   		memcpy(&rule_hw->ib.dst_gid_msk, &spec->ib.dst_gid_msk, 16);
> @@ -1384,10 +1386,18 @@ int mlx4_trans_to_dmfs_attach(struct mlx4_dev *dev, struct mlx4_qp *qp,
>   			memcpy(spec.eth.dst_mac_msk, &mac_mask, ETH_ALEN);
>   			break;
>   
> +		case MLX4_PROT_IB_IPV4:
> +			spec.id = MLX4_NET_TRANS_RULE_ID_IB;
> +			memcpy(spec.ib.dst_gid + 12, gid + 12, 4);
> +			memset(spec.ib.dst_gid_msk + 12, 0xff, 4);
> +			spec.ib.roce_type = MLX4_FLOW_SPEC_IB_ROCE_TYPE_IPV4;
> +			break;
> +
>   		case MLX4_PROT_IB_IPV6:
>   			spec.id = MLX4_NET_TRANS_RULE_ID_IB;
>   			memcpy(spec.ib.dst_gid, gid, 16);
> -			memset(&spec.ib.dst_gid_msk, 0xff, 16);
> +			memset(spec.ib.dst_gid_msk, 0xff, 16);
> +			spec.ib.roce_type = MLX4_FLOW_SPEC_IB_ROCE_TYPE_IPV6;
>   			break;
>   		default:
>   			return -EINVAL;
> diff --git a/include/linux/mlx4/device.h b/include/linux/mlx4/device.h
> index 0d873f1ae..cdc75b2 100644
> --- a/include/linux/mlx4/device.h
> +++ b/include/linux/mlx4/device.h
> @@ -391,6 +391,11 @@ enum mlx4_protocol {
>   	MLX4_PROT_FCOE
>   };
>   
> +enum mlx4_flow_roce_type {
> +	MLX4_FLOW_SPEC_IB_ROCE_TYPE_IPV6 = 0,
> +	MLX4_FLOW_SPEC_IB_ROCE_TYPE_IPV4
> +};
> +
>   enum {
>   	MLX4_MTT_FLAG_PRESENT		= 1
>   };
> @@ -1197,6 +1202,7 @@ struct mlx4_spec_ipv4 {
>   struct mlx4_spec_ib {
>   	__be32  l3_qpn;
>   	__be32	qpn_msk;
> +	enum    mlx4_flow_roce_type roce_type;
>   	u8	dst_gid[16];
>   	u8	dst_gid_msk[16];
>   };

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/net/ethernet/mellanox/mlx4/mcg.c b/drivers/net/ethernet/mellanox/mlx4/mcg.c
index 1d4e2e0..834e60e 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mcg.c
+++ b/drivers/net/ethernet/mellanox/mlx4/mcg.c
@@ -858,7 +858,9 @@  static int parse_trans_rule(struct mlx4_dev *dev, struct mlx4_spec_list *spec,
 		break;
 
 	case MLX4_NET_TRANS_RULE_ID_IB:
-		rule_hw->ib.l3_qpn = spec->ib.l3_qpn;
+		rule_hw->ib.l3_qpn = spec->ib.l3_qpn |
+			(spec->ib.roce_type == MLX4_FLOW_SPEC_IB_ROCE_TYPE_IPV4 ?
+			 (__force __be32)0x80 : (__force __be32)0);
 		rule_hw->ib.qpn_mask = spec->ib.qpn_msk;
 		memcpy(&rule_hw->ib.dst_gid, &spec->ib.dst_gid, 16);
 		memcpy(&rule_hw->ib.dst_gid_msk, &spec->ib.dst_gid_msk, 16);
@@ -1384,10 +1386,18 @@  int mlx4_trans_to_dmfs_attach(struct mlx4_dev *dev, struct mlx4_qp *qp,
 			memcpy(spec.eth.dst_mac_msk, &mac_mask, ETH_ALEN);
 			break;
 
+		case MLX4_PROT_IB_IPV4:
+			spec.id = MLX4_NET_TRANS_RULE_ID_IB;
+			memcpy(spec.ib.dst_gid + 12, gid + 12, 4);
+			memset(spec.ib.dst_gid_msk + 12, 0xff, 4);
+			spec.ib.roce_type = MLX4_FLOW_SPEC_IB_ROCE_TYPE_IPV4;
+			break;
+
 		case MLX4_PROT_IB_IPV6:
 			spec.id = MLX4_NET_TRANS_RULE_ID_IB;
 			memcpy(spec.ib.dst_gid, gid, 16);
-			memset(&spec.ib.dst_gid_msk, 0xff, 16);
+			memset(spec.ib.dst_gid_msk, 0xff, 16);
+			spec.ib.roce_type = MLX4_FLOW_SPEC_IB_ROCE_TYPE_IPV6;
 			break;
 		default:
 			return -EINVAL;
diff --git a/include/linux/mlx4/device.h b/include/linux/mlx4/device.h
index 0d873f1ae..cdc75b2 100644
--- a/include/linux/mlx4/device.h
+++ b/include/linux/mlx4/device.h
@@ -391,6 +391,11 @@  enum mlx4_protocol {
 	MLX4_PROT_FCOE
 };
 
+enum mlx4_flow_roce_type {
+	MLX4_FLOW_SPEC_IB_ROCE_TYPE_IPV6 = 0,
+	MLX4_FLOW_SPEC_IB_ROCE_TYPE_IPV4
+};
+
 enum {
 	MLX4_MTT_FLAG_PRESENT		= 1
 };
@@ -1197,6 +1202,7 @@  struct mlx4_spec_ipv4 {
 struct mlx4_spec_ib {
 	__be32  l3_qpn;
 	__be32	qpn_msk;
+	enum    mlx4_flow_roce_type roce_type;
 	u8	dst_gid[16];
 	u8	dst_gid_msk[16];
 };