From patchwork Tue Apr 11 09:10:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mika Westerberg X-Patchwork-Id: 13207240 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 2B274C7619A for ; Tue, 11 Apr 2023 09:11:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229824AbjDKJL0 (ORCPT ); Tue, 11 Apr 2023 05:11:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229900AbjDKJK7 (ORCPT ); Tue, 11 Apr 2023 05:10:59 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 034933C2A for ; Tue, 11 Apr 2023 02:10:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1681204250; x=1712740250; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UGzPkrCCdKAwn8inRum+3kkNx1UOeIU/xkT2TAn9pdw=; b=YcjVKOVKXGlpownAUkhhlW0HXzkaqkTwJbwyRgKbWFBKV//EjWHWyHVB Iq7cmMFuOB7HVMMu/scOfJW+2AzSwg4XlJlhRpV5JgNqzs6Ffp9TdoBnO J4AQmdpjAHVsVnaozvbMUvqPkCmOy+E/0LudngRiq7wSxfL0UeKiam7vs MlBt607P3IeO2hVtGDY5ga8f0MtUCEGFZt+Xdp751tXdElT1uDvOIGFHV td5gDaXvqFXQfabw36r5bL8npVup3KMQ4UzpZq7Ptlebj2BkSYQUAInFa QZhPqtrKFuUCNIwfnvheTA7X/uSg1OZv83rLzo3JAirv71ltCgcjbIVHq w==; X-IronPort-AV: E=McAfee;i="6600,9927,10676"; a="343568214" X-IronPort-AV: E=Sophos;i="5.98,336,1673942400"; d="scan'208";a="343568214" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Apr 2023 02:10:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10676"; a="753066929" X-IronPort-AV: E=Sophos;i="5.98,336,1673942400"; d="scan'208";a="753066929" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga008.fm.intel.com with ESMTP; 11 Apr 2023 02:10:46 -0700 Received: by black.fi.intel.com (Postfix, from userid 1001) id 4A1A787; Tue, 11 Apr 2023 12:10:49 +0300 (EEST) From: Mika Westerberg To: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Michael Jamet , Yehezkel Bernat , Andy Shevchenko , Simon Horman , Mika Westerberg , netdev@vger.kernel.org Subject: [PATCH v2 1/3] net: thunderbolt: Fix sparse warnings in tbnet_check_frame() and tbnet_poll() Date: Tue, 11 Apr 2023 12:10:47 +0300 Message-Id: <20230411091049.12998-2-mika.westerberg@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230411091049.12998-1-mika.westerberg@linux.intel.com> References: <20230411091049.12998-1-mika.westerberg@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Fixes the following warnings when the driver is built with sparse checks enabled: main.c:767:47: warning: restricted __le32 degrades to integer main.c:775:47: warning: restricted __le16 degrades to integer main.c:776:44: warning: restricted __le16 degrades to integer main.c:876:40: warning: incorrect type in assignment (different base types) main.c:876:40: expected restricted __le32 [usertype] frame_size main.c:876:40: got unsigned int [assigned] [usertype] frame_size main.c:877:41: warning: incorrect type in assignment (different base types) main.c:877:41: expected restricted __le32 [usertype] frame_count main.c:877:41: got unsigned int [usertype] main.c:878:41: warning: incorrect type in assignment (different base types) main.c:878:41: expected restricted __le16 [usertype] frame_index main.c:878:41: got unsigned short [usertype] main.c:879:38: warning: incorrect type in assignment (different base types) main.c:879:38: expected restricted __le16 [usertype] frame_id main.c:879:38: got unsigned short [usertype] main.c:880:62: warning: restricted __le32 degrades to integer main.c:880:35: warning: restricted __le16 degrades to integer No functional changes intended. Signed-off-by: Mika Westerberg Reviewed-by: Simon Horman Reviewed-by: Andy Shevchenko --- drivers/net/thunderbolt/main.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/net/thunderbolt/main.c b/drivers/net/thunderbolt/main.c index 26ef3706445e..27f8573a2b6e 100644 --- a/drivers/net/thunderbolt/main.c +++ b/drivers/net/thunderbolt/main.c @@ -764,7 +764,7 @@ static bool tbnet_check_frame(struct tbnet *net, const struct tbnet_frame *tf, */ if (net->skb && net->rx_hdr.frame_count) { /* Check the frame count fits the count field */ - if (frame_count != net->rx_hdr.frame_count) { + if (frame_count != le32_to_cpu(net->rx_hdr.frame_count)) { net->stats.rx_length_errors++; return false; } @@ -772,8 +772,8 @@ static bool tbnet_check_frame(struct tbnet *net, const struct tbnet_frame *tf, /* Check the frame identifiers are incremented correctly, * and id is matching. */ - if (frame_index != net->rx_hdr.frame_index + 1 || - frame_id != net->rx_hdr.frame_id) { + if (frame_index != le16_to_cpu(net->rx_hdr.frame_index) + 1 || + frame_id != le16_to_cpu(net->rx_hdr.frame_id)) { net->stats.rx_missed_errors++; return false; } @@ -873,11 +873,12 @@ static int tbnet_poll(struct napi_struct *napi, int budget) TBNET_RX_PAGE_SIZE - hdr_size); } - net->rx_hdr.frame_size = frame_size; - net->rx_hdr.frame_count = le32_to_cpu(hdr->frame_count); - net->rx_hdr.frame_index = le16_to_cpu(hdr->frame_index); - net->rx_hdr.frame_id = le16_to_cpu(hdr->frame_id); - last = net->rx_hdr.frame_index == net->rx_hdr.frame_count - 1; + net->rx_hdr.frame_size = hdr->frame_size; + net->rx_hdr.frame_count = hdr->frame_count; + net->rx_hdr.frame_index = hdr->frame_index; + net->rx_hdr.frame_id = hdr->frame_id; + last = le16_to_cpu(net->rx_hdr.frame_index) == + le32_to_cpu(net->rx_hdr.frame_count) - 1; rx_packets++; net->stats.rx_bytes += frame_size; From patchwork Tue Apr 11 09:10:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mika Westerberg X-Patchwork-Id: 13207239 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 A27D4C7619A for ; Tue, 11 Apr 2023 09:11:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230420AbjDKJLX (ORCPT ); Tue, 11 Apr 2023 05:11:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229876AbjDKJK7 (ORCPT ); Tue, 11 Apr 2023 05:10:59 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 709403C11 for ; Tue, 11 Apr 2023 02:10:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1681204250; x=1712740250; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=JuaFGXBQo2eOm57w5hQz1C8qQlWDN2O+Id+2cSGIQu8=; b=Oscv4uCslY0i7vINrZJE9wu2buZPNnAnWU6vCeyvR7KdibqGJBWDqQox /0AfTETc0tZA5XfCn0oY8iqEr9QlgFMtsMY+N6Ftra2gFZ41SNz+cXB+t zuPcN2YzW8noFjiNqwSeaNC8WXotYqCtkBRjTAdc0TUT8hAs8GePL2Kvd gqoq+0wtG1uHJsC0l2evHa1JIJ5okN9eIHKIJgslEY6AxjqcONWk3YVwU NRjUu62hc1prp6i6pmGHBE6X/4b9Er6ctRKbdXPHPmcBBlTiR7s6yDcPy IAYjiWEUnb8DB1Pf/kZnz7mfa7Skl1+mb05RglrMpQCVjtS9IqiXDe7kd A==; X-IronPort-AV: E=McAfee;i="6600,9927,10676"; a="327665010" X-IronPort-AV: E=Sophos;i="5.98,336,1673942400"; d="scan'208";a="327665010" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Apr 2023 02:10:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10676"; a="682005212" X-IronPort-AV: E=Sophos;i="5.98,336,1673942400"; d="scan'208";a="682005212" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga007.jf.intel.com with ESMTP; 11 Apr 2023 02:10:46 -0700 Received: by black.fi.intel.com (Postfix, from userid 1001) id 4D30869A; Tue, 11 Apr 2023 12:10:49 +0300 (EEST) From: Mika Westerberg To: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Michael Jamet , Yehezkel Bernat , Andy Shevchenko , Simon Horman , Mika Westerberg , netdev@vger.kernel.org Subject: [PATCH v2 2/3] net: thunderbolt: Fix sparse warnings in tbnet_xmit_csum_and_map() Date: Tue, 11 Apr 2023 12:10:48 +0300 Message-Id: <20230411091049.12998-3-mika.westerberg@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230411091049.12998-1-mika.westerberg@linux.intel.com> References: <20230411091049.12998-1-mika.westerberg@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Fixes the following warning when the driver is built with sparse checks enabled: main.c:993:23: warning: incorrect type in initializer (different base types) main.c:993:23: expected restricted __wsum [usertype] wsum main.c:993:23: got restricted __be32 [usertype] No functional changes intended. Signed-off-by: Mika Westerberg Reviewed-by: Simon Horman Reviewed-by: Andy Shevchenko --- drivers/net/thunderbolt/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/thunderbolt/main.c b/drivers/net/thunderbolt/main.c index 27f8573a2b6e..6a43ced74881 100644 --- a/drivers/net/thunderbolt/main.c +++ b/drivers/net/thunderbolt/main.c @@ -991,8 +991,10 @@ static bool tbnet_xmit_csum_and_map(struct tbnet *net, struct sk_buff *skb, { struct thunderbolt_ip_frame_header *hdr = page_address(frames[0]->page); struct device *dma_dev = tb_ring_dma_device(net->tx_ring.ring); - __wsum wsum = htonl(skb->len - skb_transport_offset(skb)); unsigned int i, len, offset = skb_transport_offset(skb); + /* Remove payload length from checksum */ + u32 paylen = skb->len - skb_transport_offset(skb); + __wsum wsum = (__force __wsum)htonl(paylen); __be16 protocol = skb->protocol; void *data = skb->data; void *dest = hdr + 1; From patchwork Tue Apr 11 09:10:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mika Westerberg X-Patchwork-Id: 13207237 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 78619C76196 for ; Tue, 11 Apr 2023 09:11:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229863AbjDKJLT (ORCPT ); Tue, 11 Apr 2023 05:11:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229738AbjDKJK5 (ORCPT ); Tue, 11 Apr 2023 05:10:57 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CB9F30F3 for ; Tue, 11 Apr 2023 02:10:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1681204249; x=1712740249; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QTpoh+zVp5ia8SwYnUrFz50Ez8HcPW5Xj7Tq/YwzLvI=; b=Ng/ZipOZxh3DWkt3iB8fwSGbtVWXXhwgJX7f3JXxG7I/UwHWGY+jVkPK rD6nKLtRcbW2JcVC9IivLOy178bF15zWoPrFIsIHb7yaJXHcfFV87mhUC mkYQIamPstgIjCzKSK+B3HAOH5A6z29zFNQiU8zRkMHNUcR1rjvlW3ob/ jEXaTowv8OC/JR+fNxxX9Y0zfiKSJ4NGK0Ifz6X+iW+WXqiEgsOoBKyaQ F70deulT1pIksQa7bHMzz+KLzz5IZ16yFyNQ4TJWFiXLeNWTeRW5U4tSq xatjt3LEFr0vP9hrOkxQuB/DJVxsMgZyDxiuJcpoacK4sXr4Pzt8ZuYwg Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10676"; a="327665002" X-IronPort-AV: E=Sophos;i="5.98,336,1673942400"; d="scan'208";a="327665002" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Apr 2023 02:10:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10676"; a="682005210" X-IronPort-AV: E=Sophos;i="5.98,336,1673942400"; d="scan'208";a="682005210" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga007.jf.intel.com with ESMTP; 11 Apr 2023 02:10:46 -0700 Received: by black.fi.intel.com (Postfix, from userid 1001) id 5580F6FC; Tue, 11 Apr 2023 12:10:49 +0300 (EEST) From: Mika Westerberg To: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Michael Jamet , Yehezkel Bernat , Andy Shevchenko , Simon Horman , Mika Westerberg , netdev@vger.kernel.org Subject: [PATCH v2 3/3] net: thunderbolt: Fix typos in comments Date: Tue, 11 Apr 2023 12:10:49 +0300 Message-Id: <20230411091049.12998-4-mika.westerberg@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230411091049.12998-1-mika.westerberg@linux.intel.com> References: <20230411091049.12998-1-mika.westerberg@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Fix two typos in comments: blongs -> belongs UPD -> UDP No functional changes. Signed-off-by: Mika Westerberg Reviewed-by: Simon Horman Reviewed-by: Andy Shevchenko --- drivers/net/thunderbolt/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/thunderbolt/main.c b/drivers/net/thunderbolt/main.c index 6a43ced74881..0c1e8970ee58 100644 --- a/drivers/net/thunderbolt/main.c +++ b/drivers/net/thunderbolt/main.c @@ -148,7 +148,7 @@ struct tbnet_ring { /** * struct tbnet - ThunderboltIP network driver private data * @svc: XDomain service the driver is bound to - * @xd: XDomain the service blongs to + * @xd: XDomain the service belongs to * @handler: ThunderboltIP configuration protocol handler * @dev: Networking device * @napi: NAPI structure for Rx polling @@ -1030,7 +1030,7 @@ static bool tbnet_xmit_csum_and_map(struct tbnet *net, struct sk_buff *skb, /* Data points on the beginning of packet. * Check is the checksum absolute place in the packet. * ipcso will update IP checksum. - * tucso will update TCP/UPD checksum. + * tucso will update TCP/UDP checksum. */ if (protocol == htons(ETH_P_IP)) { __sum16 *ipcso = dest + ((void *)&(ip_hdr(skb)->check) - data);