From patchwork Wed Nov 30 12:24:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13059768 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13997C352A1 for ; Wed, 30 Nov 2022 12:24:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234448AbiK3MYY (ORCPT ); Wed, 30 Nov 2022 07:24:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230367AbiK3MYU (ORCPT ); Wed, 30 Nov 2022 07:24:20 -0500 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F15BF2B618; Wed, 30 Nov 2022 04:24:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669811060; x=1701347060; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=CHddWfflPs8kLESzYoIMrTNSP+L+KcSfpj3rQaLl8ps=; b=oITNyRvew8KVb3YH9fOF/4xqdDIXk6ASxtByefLx6WTkLg+JJjPat0ej A2mhTITR/vgVJ4o0dZ8xvc4y7iUy3IQPlIjNwJVDAHR98J/Rh9+iUCEBA VXi5+HjXsC87fV/sEC8phzduGl9UoCbx4l0d2ddV3Q8uQfApOp6YIaEj9 MxC99YbQcfPAFer9YXEeht4lrqCv/wHWXSGsIHZTsRo0XKEAnvww9RFfb LKgdPAN+qjvacAlpolurOeshkBXGwYXj8jSFpm8pDrfd82Q8PfKGdVFx5 iCd+xTspKty9c1i8deqn1B5T9kR4L4I2Fsb624xT7nyFTOIqUnHn87btM w==; X-IronPort-AV: E=McAfee;i="6500,9779,10546"; a="401662243" X-IronPort-AV: E=Sophos;i="5.96,206,1665471600"; d="scan'208";a="401662243" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2022 04:24:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10546"; a="889272093" X-IronPort-AV: E=Sophos;i="5.96,206,1665471600"; d="scan'208";a="889272093" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga006.fm.intel.com with ESMTP; 30 Nov 2022 04:24:16 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id C505710E; Wed, 30 Nov 2022 14:24:42 +0200 (EET) From: Andy Shevchenko To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Michael Jamet , Mika Westerberg , Yehezkel Bernat , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andy Shevchenko Subject: [PATCH net-next v2 1/2] Revert "net: thunderbolt: Use separate header data type for the Rx" Date: Wed, 30 Nov 2022 14:24:38 +0200 Message-Id: <20221130122439.10822-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This reverts commit 9ad63a3dad65b984ba16f5841163457dec266be4. --- v2: added tag (Mika) drivers/net/thunderbolt.c | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/drivers/net/thunderbolt.c b/drivers/net/thunderbolt.c index 0fc2d9222a71..c73d419f1456 100644 --- a/drivers/net/thunderbolt.c +++ b/drivers/net/thunderbolt.c @@ -58,32 +58,12 @@ * supported then @frame_id is filled, otherwise it stays %0. */ struct thunderbolt_ip_frame_header { - __le32 frame_size; - __le16 frame_index; - __le16 frame_id; - __le32 frame_count; -}; - -/* Same as &struct thunderbolt_ip_frame_header for Rx */ -struct thunderbolt_ip_frame_rx_hdr { u32 frame_size; u16 frame_index; u16 frame_id; u32 frame_count; }; -static_assert(sizeof(struct thunderbolt_ip_frame_header) == - sizeof(struct thunderbolt_ip_frame_rx_hdr)); - -#define TBIP_FRAME_HDR_MATCH(x) \ - static_assert(offsetof(struct thunderbolt_ip_frame_header, frame_##x) == \ - offsetof(struct thunderbolt_ip_frame_rx_hdr, frame_##x)) -TBIP_FRAME_HDR_MATCH(size); -TBIP_FRAME_HDR_MATCH(index); -TBIP_FRAME_HDR_MATCH(id); -TBIP_FRAME_HDR_MATCH(count); -#undef TBIP_FRAME_HDR_MATCH - enum thunderbolt_ip_frame_pdf { TBIP_PDF_FRAME_START = 1, TBIP_PDF_FRAME_END, @@ -213,7 +193,7 @@ struct tbnet { struct delayed_work login_work; struct work_struct connected_work; struct work_struct disconnect_work; - struct thunderbolt_ip_frame_rx_hdr rx_hdr; + struct thunderbolt_ip_frame_header rx_hdr; struct tbnet_ring rx_ring; atomic_t frame_id; struct tbnet_ring tx_ring; From patchwork Wed Nov 30 12:24:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13059767 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F2BEC433FE for ; Wed, 30 Nov 2022 12:24:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232871AbiK3MYW (ORCPT ); Wed, 30 Nov 2022 07:24:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230006AbiK3MYT (ORCPT ); Wed, 30 Nov 2022 07:24:19 -0500 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A8982BB2F; Wed, 30 Nov 2022 04:24:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669811059; x=1701347059; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=f2Nj2e0faGv/S6d1FqA8MU+LXFErcONXYF0KNmZbZX4=; b=Xn3XWvB3ynKY8AgJw2oxMLARVkYyI6e/70eYgkN7horysSorQqh6aQq6 6qsnXoR2aynjAGOwE7tat15lVHmbAbKo+KiNOiQlODOJkT7yT/pit29NO wdb+f48PyWnW17PRBrfC1fKP7Nuea9oitjHJwILX+0THbhCTuIrm3LwwN heVQ4qSEfsExrHBGu0JzEBWioKDPK+evPCumt3ygZYjIsstYqIFX/x/Wv d/uEsPuOw5gVl03hamwTpeyi41zH6kh7ToQv7Z9OOjjPiHoX2MCjlYblU n6LrW0Fb+YtuBJvmrWl7RDFpOj6GJBK2EnaLX1MdMoO6W7r8B42K0MF43 w==; X-IronPort-AV: E=McAfee;i="6500,9779,10546"; a="401662235" X-IronPort-AV: E=Sophos;i="5.96,206,1665471600"; d="scan'208";a="401662235" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2022 04:24:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10546"; a="889272091" X-IronPort-AV: E=Sophos;i="5.96,206,1665471600"; d="scan'208";a="889272091" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga006.fm.intel.com with ESMTP; 30 Nov 2022 04:24:16 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id D46B16A; Wed, 30 Nov 2022 14:24:42 +0200 (EET) From: Andy Shevchenko To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Michael Jamet , Mika Westerberg , Yehezkel Bernat , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andy Shevchenko Subject: [PATCH net-next v2 2/2] net: thunderbolt: Use bitwise types in the struct thunderbolt_ip_frame_header Date: Wed, 30 Nov 2022 14:24:39 +0200 Message-Id: <20221130122439.10822-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221130122439.10822-1-andriy.shevchenko@linux.intel.com> References: <20221130122439.10822-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The main usage of the struct thunderbolt_ip_frame_header is to handle the packets on the media layer. The header is bound to the protocol in which the byte ordering is crucial. However the data type definition doesn't use that and sparse is unhappy, for example (17 altogether): .../thunderbolt.c:718:23: warning: cast to restricted __le32 .../thunderbolt.c:966:42: warning: incorrect type in assignment (different base types) .../thunderbolt.c:966:42: expected unsigned int [usertype] frame_count .../thunderbolt.c:966:42: got restricted __le32 [usertype] Switch to the bitwise types in the struct thunderbolt_ip_frame_header to reduce this, but not completely solving (9 left), because the same data type is used for Rx header handled locally (in CPU byte order). Signed-off-by: Andy Shevchenko --- v2: changed only types without splitting the data type (Mika) drivers/net/thunderbolt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/thunderbolt.c b/drivers/net/thunderbolt.c index c73d419f1456..4ed7f5b547e3 100644 --- a/drivers/net/thunderbolt.c +++ b/drivers/net/thunderbolt.c @@ -58,10 +58,10 @@ * supported then @frame_id is filled, otherwise it stays %0. */ struct thunderbolt_ip_frame_header { - u32 frame_size; - u16 frame_index; - u16 frame_id; - u32 frame_count; + __le32 frame_size; + __le16 frame_index; + __le16 frame_id; + __le32 frame_count; }; enum thunderbolt_ip_frame_pdf {