From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f194.google.com (mail-wr0-f194.google.com [209.85.128.194]) by dpdk.org (Postfix) with ESMTP id 439321B7DB for ; Tue, 24 Oct 2017 17:18:34 +0200 (CEST) Received: by mail-wr0-f194.google.com with SMTP id j15so8913763wre.8 for ; Tue, 24 Oct 2017 08:18:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=QmvdlKXlEsesQsww5yX7yEiucn9SrYJuUOQh5vyHArk=; b=X27AtFK4TlnxCDCFLBJpFxYpYE4T+/lLZqgWTP0hyNxY9gf3DQd5TNoPvQ4d+b+Zsy A5Hiq7q6C9u9VXTKKhY87eyLnQGp12rEnTPO/6OGF2VehPlnixeJjoB9Xyd5NkfB1slN PJ4UP19lrQ5zmfCfqaoDZtakCsNSy6XNnsTMgjp+Opv2mmDHs+GAdcbqntIq+LwVcCA9 VYzD4yEaFtwArr4kGu50oE4JsvP0pQrEL2oO6aFOR+5xBYeawwMH6KSIi0RqVDFjP1gs qb7qxSqE8tlNvIgpbUK4RvLmn6KVDJi4PgHHUbe5MvR+EoxWgy05Gs3aKXRQTMWuBjkB QjQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=QmvdlKXlEsesQsww5yX7yEiucn9SrYJuUOQh5vyHArk=; b=a1FXZk7AiAOTfAe9vZ4mqDeTa7PhbxjrYbkHWT5cGjDPvyL9GK56sU8BEzw2tqOUno jsiRa2f+LX2cGTqEfyN4uPIvUsSPnHczB2ZdyHMNBwGEHjFE612/V5q+IdI2/haxpsx8 ABwgquk4AGK2jtfK7gDps1mmp937QsV2x0vCa8igCrPitsKR6AakeqIRA56Yzpyi+c69 PNY8vAj3D/tZBGDMfzqP9OHwV33B8/7CU/8MvSSC+tJi8h2YL6mlgZzxDlARAwNqgezc UWbZEFNbZLaoi5ojANp51I3TCeAor/POVrk1qDOTR30lxzrdi30GWJ+kr8S1pVb5bo1I mV7Q== X-Gm-Message-State: AMCzsaX52IOzPeY7isNyG2urDHS0o6JxPEJVV0UBRb6Z7ecwWlm3MgYr Q+Fi9LllcUyXyDdyQudX67KjlYiyOg== X-Google-Smtp-Source: ABhQp+SSLMwB79759SZD2Q+0qLhhKfsKXLGMZwfs36Vz7h1eHtOuonNDIU1go5gBqMlUjt+S5jLp4Q== X-Received: by 10.223.169.239 with SMTP id b102mr14146016wrd.171.1508858313790; Tue, 24 Oct 2017 08:18:33 -0700 (PDT) Received: from laranjeiro-vm.dev.6wind.com. (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id v23sm637300wmh.8.2017.10.24.08.18.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Oct 2017 08:18:33 -0700 (PDT) From: Nelio Laranjeiro To: dev@dpdk.org Cc: Yongseok Koh , Adrien Mazarguil Date: Tue, 24 Oct 2017 17:18:17 +0200 Message-Id: <7815b352a375497fb46639b432126ed2f41100b0.1508857992.git.nelio.laranjeiro@6wind.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v3 6/7] net/mlx5: fix reception when VLAN is added X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Oct 2017 15:18:34 -0000 When VLAN is enabled in the Rx side, only packets matching this VLAN are expected, this also includes the broadcast and all multicast packets. Fixes: 272733b5ebfd ("net/mlx5: use flow to enable unicast traffic") Fixes: 6a6b6828fe6a ("net/mlx5: use flow to enable all multi mode") Signed-off-by: Nelio Laranjeiro --- drivers/net/mlx5/mlx5_trigger.c | 156 +++++++++++++++++++++++----------------- 1 file changed, 89 insertions(+), 67 deletions(-) diff --git a/drivers/net/mlx5/mlx5_trigger.c b/drivers/net/mlx5/mlx5_trigger.c index 29167badd..982d0a24d 100644 --- a/drivers/net/mlx5/mlx5_trigger.c +++ b/drivers/net/mlx5/mlx5_trigger.c @@ -251,6 +251,29 @@ mlx5_dev_stop(struct rte_eth_dev *dev) int priv_dev_traffic_enable(struct priv *priv, struct rte_eth_dev *dev) { + struct rte_flow_item_eth bcast = { + .dst.addr_bytes = "\xff\xff\xff\xff\xff\xff", + }; + struct rte_flow_item_eth ipv6_multi_spec = { + .dst.addr_bytes = "\x33\x33\x00\x00\x00\x00", + }; + struct rte_flow_item_eth ipv6_multi_mask = { + .dst.addr_bytes = "\xff\xff\x00\x00\x00\x00", + }; + struct rte_flow_item_eth unicast = { + .src.addr_bytes = "\x00\x00\x00\x00\x00\x00", + }; + struct rte_flow_item_eth unicast_mask = { + .dst.addr_bytes = "\xff\xff\xff\xff\xff\xff", + }; + const unsigned int vlan_filter_n = priv->vlan_filter_n; + const struct ether_addr cmp = { + .addr_bytes = "\x00\x00\x00\x00\x00\x00", + }; + unsigned int i; + unsigned int j; + int ret; + if (priv->isolated) return 0; if (dev->data->promiscuous) { @@ -261,81 +284,80 @@ priv_dev_traffic_enable(struct priv *priv, struct rte_eth_dev *dev) }; claim_zero(mlx5_ctrl_flow(dev, &promisc, &promisc)); - } else if (dev->data->all_multicast) { + return 0; + } + if (dev->data->all_multicast) { struct rte_flow_item_eth multicast = { .dst.addr_bytes = "\x01\x00\x00\x00\x00\x00", - .src.addr_bytes = "\x01\x00\x00\x00\x00\x00", + .src.addr_bytes = "\x00\x00\x00\x00\x00\x00", .type = 0, }; claim_zero(mlx5_ctrl_flow(dev, &multicast, &multicast)); } else { - struct rte_flow_item_eth bcast = { - .dst.addr_bytes = "\xff\xff\xff\xff\xff\xff", - }; - struct rte_flow_item_eth ipv6_multi_spec = { - .dst.addr_bytes = "\x33\x33\x00\x00\x00\x00", - }; - struct rte_flow_item_eth ipv6_multi_mask = { - .dst.addr_bytes = "\xff\xff\x00\x00\x00\x00", - }; - struct rte_flow_item_eth unicast = { - .src.addr_bytes = "\x00\x00\x00\x00\x00\x00", - }; - struct rte_flow_item_eth unicast_mask = { - .dst.addr_bytes = "\xff\xff\xff\xff\xff\xff", - }; - const unsigned int vlan_filter_n = priv->vlan_filter_n; - const struct ether_addr cmp = { - .addr_bytes = "\x00\x00\x00\x00\x00\x00", - }; - unsigned int i; - unsigned int j; - unsigned int unicast_flow = 0; - int ret; - - for (i = 0; i != MLX5_MAX_MAC_ADDRESSES; ++i) { - struct ether_addr *mac = &dev->data->mac_addrs[i]; - - if (!memcmp(mac, &cmp, sizeof(*mac))) - continue; - memcpy(&unicast.dst.addr_bytes, - mac->addr_bytes, - ETHER_ADDR_LEN); - for (j = 0; j != vlan_filter_n; ++j) { - uint16_t vlan = priv->vlan_filter[j]; - - struct rte_flow_item_vlan vlan_spec = { - .tci = rte_cpu_to_be_16(vlan), - }; - struct rte_flow_item_vlan vlan_mask = { - .tci = 0xffff, - }; - - ret = mlx5_ctrl_flow_vlan(dev, &unicast, - &unicast_mask, - &vlan_spec, - &vlan_mask); - if (ret) - goto error; - unicast_flow = 1; - } - if (!vlan_filter_n) { - ret = mlx5_ctrl_flow(dev, &unicast, - &unicast_mask); - if (ret) - goto error; - unicast_flow = 1; - } + /* Add broadcast/multicast flows. */ + for (i = 0; i != vlan_filter_n; ++i) { + uint16_t vlan = priv->vlan_filter[i]; + + struct rte_flow_item_vlan vlan_spec = { + .tci = rte_cpu_to_be_16(vlan), + }; + struct rte_flow_item_vlan vlan_mask = { + .tci = 0xffff, + }; + + ret = mlx5_ctrl_flow_vlan(dev, &bcast, &bcast, + &vlan_spec, &vlan_mask); + if (ret) + goto error; + ret = mlx5_ctrl_flow_vlan(dev, &ipv6_multi_spec, + &ipv6_multi_mask, + &vlan_spec, &vlan_mask); + if (ret) + goto error; + } + if (!vlan_filter_n) { + ret = mlx5_ctrl_flow(dev, &bcast, &bcast); + if (ret) + goto error; + ret = mlx5_ctrl_flow(dev, &ipv6_multi_spec, + &ipv6_multi_mask); + if (ret) + goto error; + } + } + /* Add MAC address flows. */ + for (i = 0; i != MLX5_MAX_MAC_ADDRESSES; ++i) { + struct ether_addr *mac = &dev->data->mac_addrs[i]; + + if (!memcmp(mac, &cmp, sizeof(*mac))) + continue; + memcpy(&unicast.dst.addr_bytes, + mac->addr_bytes, + ETHER_ADDR_LEN); + for (j = 0; j != vlan_filter_n; ++j) { + uint16_t vlan = priv->vlan_filter[j]; + + struct rte_flow_item_vlan vlan_spec = { + .tci = rte_cpu_to_be_16(vlan), + }; + struct rte_flow_item_vlan vlan_mask = { + .tci = 0xffff, + }; + + ret = mlx5_ctrl_flow_vlan(dev, &unicast, + &unicast_mask, + &vlan_spec, + &vlan_mask); + if (ret) + goto error; + } + if (!vlan_filter_n) { + ret = mlx5_ctrl_flow(dev, &unicast, + &unicast_mask); + if (ret) + goto error; } - if (!unicast_flow) - return 0; - ret = mlx5_ctrl_flow(dev, &bcast, &bcast); - if (ret) - goto error; - ret = mlx5_ctrl_flow(dev, &ipv6_multi_spec, &ipv6_multi_mask); - if (ret) - goto error; } return 0; error: -- 2.11.0