From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A639843AE0; Thu, 8 Feb 2024 16:09:14 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2D5814028B; Thu, 8 Feb 2024 16:09:14 +0100 (CET) Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2118.outbound.protection.outlook.com [40.107.105.118]) by mails.dpdk.org (Postfix) with ESMTP id E330940278 for ; Thu, 8 Feb 2024 16:09:12 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CZWdO9+wRd9o1iYnygMuSb+hz7hLNGpx1enFldbATJdoG93tKGo279dL1uLvJXlsdWpj0vx347c2tXEMmOgTpkBfU1qzjWeSMwwdJg+2bMzz24IAiRvwdBQ2koGYvMWac6RCHWA4+G9R2Lz5SdHWL54p7h2TXjEpaLbQlgQsn992D230GrluBlHAT4j2qwR0O029hVYCa9fKh9qep/rHReTSJyOMpUY4ABe1EwfobyW17fTwL31KgdqShWNv9fxbkN9XVVZxvBIRmSI6Jr4fu05gpR3lEU3iUTrcOzMyHOw521vHDCTxXudJp/t0zn1Gyu6v6Ux3X7w26iVii/9hFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ezp+8G3lANxK0rlEK/CBPEUI6Byywh5ondSgtQRoOSE=; b=SeLstWi2PDPzfe4OHeWowrAUKRQY9TYgZUL/s1JJPMF1OX8ZvZA+KXOR0nuJee0ObNtz1Z+kEVM8MGKWffROChcFYw/pl2ZiYFmkxfY85XS9VRNeY3gGsE0dsdxiP2Rf+aMTgEzM8jIHLLLDdIWe0hoilHO569NDzEzMPK36xsK7a7lQVAHic+Qoo8XYJ/sCRrH+que1rwUthGN3Sy3pK4p1jSyb809WejF0+SzpGjtEVst3lHNuBv6W1QIIALJIoTgxLGDEh799+BwbvrqpMw37enol0T1gqg3ELNxSmEGyTxQWQLIZ8CaGgmN+oG5JtT4evD6uN6Fg8UDihVL9Vw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ezp+8G3lANxK0rlEK/CBPEUI6Byywh5ondSgtQRoOSE=; b=XsWmUuexz2uxTDiBQ/x1h+HYQW3D92UuvbKJCUi3Psmto0fcT2woBMaFTduMQbDyspBYVq2ppSYLnwp8Q9DbBt2JCzu+s8qY6cmoSJU/1fytowGckUw9RWxz60oK+Kj76oBSW1rhutLR9yQInyQo/q3q9MBJHMayI1d8y0dVFlA= Received: from PA4PR83MB0526.EURPRD83.prod.outlook.com (2603:10a6:102:26b::17) by DU5PR83MB0593.EURPRD83.prod.outlook.com (2603:10a6:10:525::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.8; Thu, 8 Feb 2024 15:09:10 +0000 Received: from PA4PR83MB0526.EURPRD83.prod.outlook.com ([fe80::b55f:3890:59e4:b623]) by PA4PR83MB0526.EURPRD83.prod.outlook.com ([fe80::b55f:3890:59e4:b623%7]) with mapi id 15.20.7292.009; Thu, 8 Feb 2024 15:09:10 +0000 From: Alan Elder To: Long Li CC: "dev@dpdk.org" Subject: [PATCH v3] net/netvsc: fix parsing of VLAN metadata Thread-Topic: [PATCH v3] net/netvsc: fix parsing of VLAN metadata Thread-Index: AdpaoGUQ/GGHCYC5Qr2VuZTigqp7Gw== Date: Thu, 8 Feb 2024 15:09:10 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ActionId=56178cb2-c070-454c-9d7f-d5fa4a8e41c0; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ContentBits=0; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=true; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Method=Standard; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=Internal; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2024-02-08T14:59:43Z; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PA4PR83MB0526:EE_|DU5PR83MB0593:EE_ x-ms-office365-filtering-correlation-id: b4c0787d-527b-42e0-4a17-08dc28b7e76d x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 6az1gizj/ORnrThirvEc9uN23IgwkG+H+A7ty0xYe2q2WcYjssfA6Noax1MMKeMMqZWS1QLXbgLQ2X6BjDzMkzgPoaC2Qaxf4lnBM87NE/6+cgo9fPqUKN4PavxS+DsgR+cTuYq2N+ykPwmmYsAjb+mIllWg7fiDFWJ6c9WUY3rkgNM9H9cIdm2wTw0dLI0kDoo9XwUnrMFqhIPTSXiqCSBQnCYdI7pUEesOooB5QodSGAMsFegW9rHQJZ+Qnou6mUDbwz8kYhjUOs8HYG0jBQ+m44om1VxC4I54wrJAHDJgZvlzTzNDVI3oYL+ZxaOmBk18hPy1VXo3c0MbnxzMabbWbVkijGPr8ZK6B4+WkcGdZooCUdP4qOUVn/Ag2TTX6Jla52HUk/ZJjqmjc5pVDnQ+7kFDuT8HAXWB2Pt3m8bO5mp9z6vm9NVmrRMrbpXdgCSj0KXUgFSkb6kFia+T5W5ws1+hMzZV1qTPoJ8V7UhSd4SE8xV+h+a7PWpnscpOpR3N07ZR6obmgfUHQ7RXmmLOFuuswEQekuWcBl0XdCtT07wb2Ub/00/P/x6e8nW7bIovK4o9wo7K/Re7S1qlxInhWL2R8ZMocKV5bjJdPA5Mn16JDlA5tUOiHvtmT9ty x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PA4PR83MB0526.EURPRD83.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(396003)(376002)(366004)(136003)(39860400002)(346002)(230922051799003)(64100799003)(1800799012)(451199024)(186009)(2906002)(52536014)(44832011)(5660300002)(55016003)(41300700001)(83380400001)(122000001)(86362001)(26005)(38100700002)(8990500004)(6506007)(10290500003)(9686003)(64756008)(6636002)(66556008)(7696005)(71200400001)(8936002)(66446008)(66476007)(6862004)(478600001)(33656002)(66946007)(8676002)(76116006)(82950400001)(82960400001)(38070700009)(4326008)(316002); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?wNzsdfxxymZ6TsJNtyv8wJ3tFkmFoDUGyHKq8iRM/qkXR9hcOgCzrcCgm0q5?= =?us-ascii?Q?PN0q0o/u91cU0xBoYONup4+scv5hVwFlS3AaeoaI8lzgP522qu7pj86CDMEN?= =?us-ascii?Q?G4WWJOQsFR1GoOr8I5qJrNFPMpv1GSCNEQ96bxY7B/9Ofa+kDT7E7EVjy8IF?= =?us-ascii?Q?06cpDu1TWO5VaATH/rdHNEFUss8Pxgm4XZgvBMrutPxB7yonKxoT7GbhinG4?= =?us-ascii?Q?188/fIrQhQjiOjW2Hy+X/H1C6x8Id80ouJp+tZrbo5y+j6I4R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1uhKI9kb5N8sYudz+/Llzw4B731xzz7wNK?= =?us-ascii?Q?yxwx/wJ3YnRP/CuJxVNDu+1HzSuiLWOSTTPXNp/Lz83m5UFsjc/WdBHa6kMG?= =?us-ascii?Q?tUb2gNj8s8pPiJ8Gn1mPdP9QqrP1mYP+nhEZL9eoCvjrln+LuqJ9o2vkx+2Z?= =?us-ascii?Q?k2RHB7JEEE3GvYrzDnGs1/fw3Q8+ssxSnn8Y2DM09BSzz1Jou97ATM3ixe61?= =?us-ascii?Q?O7AnD2nsciNRM+XQB/CLc8z1V30YxlSlczPQ0lN3CvLZRmmLTSoUH0oxGFvc?= =?us-ascii?Q?836m9KzIat0CuMjgBQWgy/cDzeCNnokqdUlXDkZUMVQxZD+eYLkFxAOPGgnv?= =?us-ascii?Q?GzpV1CJNG6dot4o3+KTT0LpaQFsPaItufNTu?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PA4PR83MB0526.EURPRD83.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: b4c0787d-527b-42e0-4a17-08dc28b7e76d X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Feb 2024 15:09:10.6525 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: u/8GSMdNLo1zfJhqJ2Y1aTo/vX5wQwGxZ2BI0uzOeh9yMVrQzRLKwLtuP/HOpFXluDQ6d0jL/lDOWIfpC9iaaA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU5PR83MB0593 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The previous code incorrectly parsed the VLAN ID and priority. If the 16-bits of VLAN ID and priority/CFI on the wire was 0123456789ABCDEF the code parsed it as 456789ABCDEF3012. There were macros defined to handle this conversion but they were not used. This fix takes an approach similar to the Linux netvsc driver and defines an explicit structure to use for parsing. Fixes: 4e9c73e96e83 ("net/netvsc: add Hyper-V network device") Cc: sthemmin@microsoft.com Cc: stable@dpdk.org Signed-off-by: Alan Elder --- .mailmap | 1 + drivers/net/netvsc/hn_rxtx.c | 23 +++++++++++++++++------ drivers/net/netvsc/ndis.h | 23 +++++++++++++---------- 3 files changed, 31 insertions(+), 16 deletions(-) diff --git a/.mailmap b/.mailmap index a0756974e2..eca02318d6 100644 --- a/.mailmap +++ b/.mailmap @@ -33,6 +33,7 @@ Alain Leon Alan Brady Alan Carew Alan Dewar +Alan Elder Alan Liu Alan Winkowski Alejandro Lucero diff --git a/drivers/net/netvsc/hn_rxtx.c b/drivers/net/netvsc/hn_rxtx.c index e4f5015aa3..e3b9899f1e 100644 --- a/drivers/net/netvsc/hn_rxtx.c +++ b/drivers/net/netvsc/hn_rxtx.c @@ -42,8 +42,13 @@ #define HN_TXD_CACHE_SIZE 32 /* per cpu tx_descriptor pool cache */ #define HN_RXQ_EVENT_DEFAULT 2048 =20 +#define HN_VLAN_PRIO_MASK 0xe000 /* Priority Code Point */ +#define HN_VLAN_PRIO_SHIFT 13 +#define HN_VLAN_CFI_MASK 0x1000 /* Canonical Format Indicator / Drop Eligi= ble Indicator */ +#define HN_VLAN_VID_MASK 0x0fff /* VLAN Identifier */ + struct hn_rxinfo { - uint32_t vlan_info; + struct ndis_pkt_vlan_info vlan_info; uint32_t csum_info; uint32_t hash_info; uint32_t hash_value; @@ -477,7 +482,7 @@ hn_rndis_rxinfo(const void *info_data, unsigned int inf= o_dlen, case NDIS_PKTINFO_TYPE_VLAN: if (unlikely(dlen < NDIS_VLAN_INFO_SIZE)) return -EINVAL; - info->vlan_info =3D *((const uint32_t *)data); + info->vlan_info =3D *((const struct ndis_pkt_vlan_info *)data); mask |=3D HN_RXINFO_VLAN; break; =20 @@ -611,8 +616,10 @@ static void hn_rxpkt(struct hn_rx_queue *rxq, struct h= n_rx_bufinfo *rxb, RTE_PTYPE_L3_MASK | RTE_PTYPE_L4_MASK); =20 - if (info->vlan_info !=3D HN_NDIS_VLAN_INFO_INVALID) { - m->vlan_tci =3D info->vlan_info; + if (info->vlan_info.value !=3D HN_NDIS_VLAN_INFO_INVALID) { + m->vlan_tci =3D info->vlan_info.vlanid | + (info->vlan_info.pri << HN_VLAN_PRIO_SHIFT) | + (info->vlan_info.cfi ? HN_VLAN_CFI_MASK : 0); m->ol_flags |=3D RTE_MBUF_F_RX_VLAN_STRIPPED | RTE_MBUF_F_RX_VLAN; =20 /* NDIS always strips tag, put it back if necessary */ @@ -669,7 +676,7 @@ static void hn_rndis_rx_data(struct hn_rx_queue *rxq, unsigned int pktinfo_off, pktinfo_len; const struct rndis_packet_msg *pkt =3D data; struct hn_rxinfo info =3D { - .vlan_info =3D HN_NDIS_VLAN_INFO_INVALID, + .vlan_info.value =3D HN_NDIS_VLAN_INFO_INVALID, .csum_info =3D HN_NDIS_RXCSUM_INFO_INVALID, .hash_info =3D HN_NDIS_HASH_INFO_INVALID, }; @@ -1332,7 +1339,11 @@ static void hn_encap(struct rndis_packet_msg *pkt, if (m->ol_flags & RTE_MBUF_F_TX_VLAN) { pi_data =3D hn_rndis_pktinfo_append(pkt, NDIS_VLAN_INFO_SIZE, NDIS_PKTINFO_TYPE_VLAN); - *pi_data =3D m->vlan_tci; + struct ndis_pkt_vlan_info *vlan =3D (struct ndis_pkt_vlan_info *)pi_data= ; + vlan->value =3D 0; + vlan->vlanid =3D (m->vlan_tci & HN_VLAN_VID_MASK); + vlan->cfi =3D (!!(m->vlan_tci & HN_VLAN_CFI_MASK)); + vlan->pri =3D ((m->vlan_tci & HN_VLAN_PRIO_MASK) >> HN_VLAN_PRIO_SHIFT); } =20 if (m->ol_flags & RTE_MBUF_F_TX_TCP_SEG) { diff --git a/drivers/net/netvsc/ndis.h b/drivers/net/netvsc/ndis.h index d97a397a86..a1e587c738 100644 --- a/drivers/net/netvsc/ndis.h +++ b/drivers/net/netvsc/ndis.h @@ -316,16 +316,19 @@ struct ndis_offload { */ =20 /* VLAN */ -#define NDIS_VLAN_INFO_SIZE sizeof(uint32_t) -#define NDIS_VLAN_INFO_PRI_MASK 0x0007 -#define NDIS_VLAN_INFO_CFI_MASK 0x0008 -#define NDIS_VLAN_INFO_ID_MASK 0xfff0 -#define NDIS_VLAN_INFO_MAKE(id, pri, cfi) \ - (((pri) & NDIS_VLAN_INFO_PRI_MASK) | \ - (((cfi) & 0x1) << 3) | (((id) & 0xfff) << 4)) -#define NDIS_VLAN_INFO_ID(inf) (((inf) & NDIS_VLAN_INFO_ID_MASK) >> 4) -#define NDIS_VLAN_INFO_CFI(inf) (((inf) & NDIS_VLAN_INFO_CFI_MASK) >> 3) -#define NDIS_VLAN_INFO_PRI(inf) ((inf) & NDIS_VLAN_INFO_PRI_MASK) +struct ndis_pkt_vlan_info { + union { + struct { + uint32_t pri:3; /* User Priority */ + uint32_t cfi:1; /* Canonical Format ID / DEI */ + uint32_t vlanid:12; /* VLAN ID */ + uint32_t reserved:16; + }; + uint32_t value; + }; +}; + +#define NDIS_VLAN_INFO_SIZE sizeof(struct ndis_pkt_vlan_info) =20 /* Reception checksum */ #define NDIS_RXCSUM_INFO_SIZE sizeof(uint32_t) --=20 2.25.1