Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp840272ybh; Tue, 21 Jul 2020 09:08:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyOiPG2B3F/FemugK+EoIST8sZvXPza72ISZm5sM+09rSsj73as3JyMyldv2qArai2WzgEv X-Received: by 2002:a17:906:a1cc:: with SMTP id bx12mr24965864ejb.461.1595347687525; Tue, 21 Jul 2020 09:08:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595347687; cv=none; d=google.com; s=arc-20160816; b=sZhf0dhPGKrW2zoqrIpvUrzTMbOwUEA29lwiRP4Vog7xB9E/r21CXccPLeDteTzQbx 5j7Cf6a4DWELDFJC7JsOkAPxh3AqOI9PelY5yVn0O2iHcz/RLTWxeYERsgIiCLvmj4Ij UFdQDxjYt0WYDlrG6YfE5vOp/4nbUG+HhRxqDce2MHr6K/65rGPrwEt+TI384KoH0uPh AgEjo4a2LMwCpRIvPYWr+MyEzkUzJlvVhyokw7o1Vc/kuhd1hSJU5RDj74OOlC6ARIv8 6G/Upfoi4ayEef6qSO2eMDCycnROMhw61FOo89vZuFlCpNwFTzFQYbOgrYrI6U4txALi ZIeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=X76qDdvqpY4nYWZrENAHgAtFIsqrQGQH3lKvBOm1pNA=; b=MJ7TFU9EGymDRgBq6gdtwtiJ3Ll777OU2nqeM22RmaDqjLkadbf1AKcL/Hs9hdUKhM 1C1bBvBokMK6n8Ezawrcz4AW1FMm3NBreSaxCVURf6sbNis1L0JH2XaZ92boLpmSOYsg bX2VOh/ovOS7bXTBLbigWpskN3zYjKKvDLnlRR++URcI4K4Ltu0WEI0vVa8DHMXIbk3z J/QjImEslqVy+uH/JSZtsXF1XiZM6SIhh1mUOq/w57ervBM/rXqhQyweZeObwnHQUgYO tsgGk7B0AVgYRS4pyEc4mDIrhssDSXdlBwS2BqWEf7bxQg1Y7Da4q3fOFfYw0fPEGF5m +kag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@networkplumber-org.20150623.gappssmtp.com header.s=20150623 header.b=YHbY+bB7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id kt13si12520357ejb.297.2020.07.21.09.07.44; Tue, 21 Jul 2020 09:08:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@networkplumber-org.20150623.gappssmtp.com header.s=20150623 header.b=YHbY+bB7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728755AbgGUQFj (ORCPT + 99 others); Tue, 21 Jul 2020 12:05:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728458AbgGUQFj (ORCPT ); Tue, 21 Jul 2020 12:05:39 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F071DC061794 for ; Tue, 21 Jul 2020 09:05:38 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id m16so10457441pls.5 for ; Tue, 21 Jul 2020 09:05:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=X76qDdvqpY4nYWZrENAHgAtFIsqrQGQH3lKvBOm1pNA=; b=YHbY+bB7w+LIQELxXvSqTfqeyBXTHWIdwQ+MiYbvaC79ApWPrJxf7gOf5o/3VDqfTF PoZuQXdqT6jImKy4+YUXCp/JICHZDi+Z1ediPsb6gxWqA8wI86VzeSoIOTTzDkEzOpKx nyjN7ifWqKUrBOuZW1nvgvWOb57IePorLdIR+b6/Zf1ibMfOBZjGYuPHNNAXiyhbrAg6 rHHtWhPIPKy2c3IQxedlshUwT2MCnOR2Gt/FjLTtLYIA8RHifqQ+qNjz0PxcZ9QHu2V4 0IXhhYm3MhY5m683IxZJkkrbhwhjl89/MEzEc209B46bsgzKm7AYwWYd/qzlqMXQFQDb uEqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=X76qDdvqpY4nYWZrENAHgAtFIsqrQGQH3lKvBOm1pNA=; b=pAzKxAXJUW4f+Ys+Y/0SmqNrHbpiL76OPYSwCHWKphNx3mEXsVO6H8MBdrlzhqzmX4 KMmy3ftytRsbiesf8rhCydSUCTo0qrtsEV6U9oHeWUxv9118UrzkLuyhAfB9XqgEGOyy +zZOfWCd7h9ygvGx6eedWAn61cXVq7kT6+W7Vb2nqv0IeDIdapWMyRDpRuheIfavl0bZ GSB7Fim6HMnqTyn2AV1f9bYVrYV3co+Uhnp2jfVdcpjKpqe9HVlHEUhvuI1wLQcf3Ezp d/RFsovMhK+zRrtWVEwGSvha9LhTX+ANWqGxjFL91dQpVuTlNheL+O0UX6/B8qeYKi// muWw== X-Gm-Message-State: AOAM530A36cFX4PXp7ZlP2svBFR+Outivs97DN0Lofvc8Mjod1mIQ7qx 79Z+9oXGrsKo+H2cqHyFvz+IdQ== X-Received: by 2002:a17:90a:748c:: with SMTP id p12mr5327243pjk.115.1595347538417; Tue, 21 Jul 2020 09:05:38 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id i13sm3620963pjd.33.2020.07.21.09.05.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jul 2020 09:05:38 -0700 (PDT) Date: Tue, 21 Jul 2020 09:05:28 -0700 From: Stephen Hemminger To: Sriram Krishnan Cc: "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Wei Liu , mbumgard@cisco.com, ugm@cisco.com, nimm@cisco.com, xe-linux-external@cisco.com, "David S. Miller" , Jakub Kicinski , linux-hyperv@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4] hv_netvsc: add support for vlans in AF_PACKET mode Message-ID: <20200721090528.2c9f104d@hermes.lan> In-Reply-To: <20200721071404.70230-1-srirakr2@cisco.com> References: <20200721071404.70230-1-srirakr2@cisco.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 21 Jul 2020 12:44:03 +0530 Sriram Krishnan wrote: > + /* When using AF_PACKET we need to drop VLAN header from > + * the frame and update the SKB to allow the HOST OS > + * to transmit the 802.1Q packet > + */ > + if (skb->protocol == htons(ETH_P_8021Q)) { > + u16 vlan_tci = 0; Unnecessary initialization. > + skb_reset_mac_header(skb); > + if (eth_type_vlan(eth_hdr(skb)->h_proto)) { > + int pop_err; > + pop_err = __skb_vlan_pop(skb, &vlan_tci); > + if (likely(pop_err == 0)) { > + __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), vlan_tci); > + /* Update the NDIS header pkt lengths */ > + packet->total_data_buflen -= VLAN_HLEN; > + rndis_msg->msg_len = packet->total_data_buflen; > + rndis_msg->msg.pkt.data_len = packet->total_data_buflen; > + } else { > + netdev_err(net, "Pop vlan err %x\n", pop_err); > + goto drop; > + } > + } > + } Printing error messages is good for debugging but bad IRL. Users ignore it, or it overflows the log buffer. A better alternative would be to add a counter to netvsc_ethtool_stats. Something like: diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h index abda736e7c7d..2181d4538ab7 100644 --- a/drivers/net/hyperv/hyperv_net.h +++ b/drivers/net/hyperv/hyperv_net.h @@ -897,6 +897,7 @@ struct netvsc_ethtool_stats { unsigned long rx_no_memory; unsigned long stop_queue; unsigned long wake_queue; + unsigned long vlan_error; }; struct netvsc_ethtool_pcpu_stats { diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c index 6267f706e8ee..89568276e653 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -605,6 +605,28 @@ static int netvsc_xmit(struct sk_buff *skb, struct net_device *net, bool xdp_tx) *hash_info = hash; } + /* When using AF_PACKET we need to drop VLAN header from + * the frame and update the SKB to allow the HOST OS + * to transmit the 802.1Q packet + */ + if (skb->protocol == htons(ETH_P_8021Q)) { + skb_reset_mac_header(skb); + if (eth_type_vlan(eth_hdr(skb)->h_proto)) { + u16 vlan_tci; + + if (unlikely(__skb_vlan_pop(skb, &vlan_tci) != 0)) { + ++net_device_ctx->eth_stats.vlan_error; + goto drop; + } + + __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), vlan_tci); + /* Update the NDIS header pkt lengths */ + packet->total_data_buflen -= VLAN_HLEN; + rndis_msg->msg_len = packet->total_data_buflen; + rndis_msg->msg.pkt.data_len = packet->total_data_buflen; + } + } + if (skb_vlan_tag_present(skb)) { struct ndis_pkt_8021q_info *vlan; @@ -1427,6 +1449,7 @@ static const struct { { "rx_no_memory", offsetof(struct netvsc_ethtool_stats, rx_no_memory) }, { "stop_queue", offsetof(struct netvsc_ethtool_stats, stop_queue) }, { "wake_queue", offsetof(struct netvsc_ethtool_stats, wake_queue) }, + { "vlan_error", offsetof(struct netvsc_ethtool_stats, vlan_error) }, }, pcpu_stats[] = { { "cpu%u_rx_packets", offsetof(struct netvsc_ethtool_pcpu_stats, rx_packets) },