Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp48168ybh; Mon, 20 Jul 2020 10:00:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy45hUevGFoQaNx/bNlBxypEXLu5MzQogo/jGcn0BWSakRV7AsmljOmv1I+zryEWU8HeZBg X-Received: by 2002:aa7:d4d2:: with SMTP id t18mr21824942edr.166.1595264406076; Mon, 20 Jul 2020 10:00:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595264406; cv=none; d=google.com; s=arc-20160816; b=NVjkRgMgC9uYFMibB0gfuiDvcBFkltSCExb3ppkJ/WlivOeGFi9Ec0jatYpzPJJKYH kohsWGzeo44rO3SIU661qAPnO+rpyWTOeWpkJ4Jd50Ih5ljAmeKN4KUwbtz3z4J3/FTx ZdCZCcx1T9B4pUJPp5rdq+9SlWCCayRfo7oxmIKWpRp/46Qw82gGgt1uDruePWdi2MIX rRZLT0s9PoV8Lmhzk1NnxsKbHWmfy7lsenlqtXyVOl2Q2pEOwOc93e5ozosH2wQBvJTK 3M8PtlMs/9A68pN3dXFmjsstRqLbss1fWp3HpqGauGlQFy2XgxnxJg3tGsyP+5NPFQfs 7Glw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=wq/HG2wN64kJj6fb3o9G8/jhw4U/26F2nKCG9d1GLZs=; b=tZG/QOBJAh5+2IMF1VMtEaYR4U+22BHqFQ+QOYru1mx11QoJNEN3le8Sz3PTgVyq2u f6IMpTsz4P+LZ/GDznJOeOjBRlL5q/oxTGXuo3N6Z/5I+Vvj/3O8K4VBPpZA1Fdr6cEI sKL2uKBRNZAqCxQC8ZQ+blbJ42Xn0cfZ7DG94LptsknlqZuCD0GlttTXlSsce4rEFByo LHoKcvoQM4Gk8zwsB4R36M6QeO2Iw04VKVwJtyK0eZcZAXNTpvBSLBL1W/OZ+g2iVTPd qnW1Km0MrzOrXz+aV3Fy2qeTt5OLOeNCyLmgx9tkDW8LM6t7mvgoF6LBXf+PbwIVSSh8 MkBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=pggpCSV+; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lo2si9659212ejb.709.2020.07.20.09.59.41; Mon, 20 Jul 2020 10:00:06 -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=@ti.com header.s=ti-com-17Q1 header.b=pggpCSV+; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730507AbgGTQ6L (ORCPT + 99 others); Mon, 20 Jul 2020 12:58:11 -0400 Received: from lelv0143.ext.ti.com ([198.47.23.248]:46868 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729941AbgGTQ6K (ORCPT ); Mon, 20 Jul 2020 12:58:10 -0400 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 06KGw5BF079972; Mon, 20 Jul 2020 11:58:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1595264285; bh=wq/HG2wN64kJj6fb3o9G8/jhw4U/26F2nKCG9d1GLZs=; h=From:To:Subject:Date:In-Reply-To:References; b=pggpCSV+jUMiouI1P11dgQ/6W+SNqGMM0+JVl/GY/M4SrGhJYsjI3G3MEe47XE+zk LjBMx8lNIq3m3n1+52uM5FafB4zG95BvpPF5nyTk85iTOg/d7jznm7e9OVqswTCJcO MzFwZC6pbGcHrXkGJvygzWi3j5ZEirrCdpoXRgvo= Received: from DLEE112.ent.ti.com (dlee112.ent.ti.com [157.170.170.23]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 06KGw5nr128546 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 20 Jul 2020 11:58:05 -0500 Received: from DLEE112.ent.ti.com (157.170.170.23) by DLEE112.ent.ti.com (157.170.170.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3; Mon, 20 Jul 2020 11:58:05 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DLEE112.ent.ti.com (157.170.170.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3 via Frontend Transport; Mon, 20 Jul 2020 11:58:05 -0500 Received: from uda0868495.fios-router.home (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 06KGw3B5041101; Mon, 20 Jul 2020 11:58:04 -0500 From: Murali Karicheri To: , , , , , , , Subject: [net-next v4 PATCH 2/7] net: hsr: introduce common code for skb initialization Date: Mon, 20 Jul 2020 12:57:58 -0400 Message-ID: <20200720165803.17793-3-m-karicheri2@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200720165803.17793-1-m-karicheri2@ti.com> References: <20200720165803.17793-1-m-karicheri2@ti.com> MIME-Version: 1.0 Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As a preparatory patch to introduce PRP protocol support in the driver, refactor the skb init code to a separate function. Signed-off-by: Murali Karicheri --- net/hsr/hsr_device.c | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/net/hsr/hsr_device.c b/net/hsr/hsr_device.c index 40ac45123a62..bfe2d1449dbd 100644 --- a/net/hsr/hsr_device.c +++ b/net/hsr/hsr_device.c @@ -230,15 +230,11 @@ static const struct header_ops hsr_header_ops = { .parse = eth_header_parse, }; -static void send_hsr_supervision_frame(struct hsr_port *master, - u8 type, u8 hsr_ver) +static struct sk_buff *hsr_init_skb(struct hsr_port *master, u8 hsr_ver) { + struct hsr_priv *hsr = master->hsr; struct sk_buff *skb; int hlen, tlen; - struct hsr_tag *hsr_tag; - struct hsr_sup_tag *hsr_stag; - struct hsr_sup_payload *hsr_sp; - unsigned long irqflags; hlen = LL_RESERVED_SPACE(master->dev); tlen = master->dev->needed_tailroom; @@ -247,22 +243,44 @@ static void send_hsr_supervision_frame(struct hsr_port *master, sizeof(struct hsr_sup_payload) + hlen + tlen); if (!skb) - return; + return skb; skb_reserve(skb, hlen); - skb->dev = master->dev; skb->protocol = htons(hsr_ver ? ETH_P_HSR : ETH_P_PRP); skb->priority = TC_PRIO_CONTROL; if (dev_hard_header(skb, skb->dev, (hsr_ver ? ETH_P_HSR : ETH_P_PRP), - master->hsr->sup_multicast_addr, + hsr->sup_multicast_addr, skb->dev->dev_addr, skb->len) <= 0) goto out; + skb_reset_mac_header(skb); skb_reset_network_header(skb); skb_reset_transport_header(skb); + return skb; +out: + kfree_skb(skb); + + return NULL; +} + +static void send_hsr_supervision_frame(struct hsr_port *master, + u8 type, u8 hsr_ver) +{ + struct hsr_sup_payload *hsr_sp; + struct hsr_sup_tag *hsr_stag; + struct hsr_tag *hsr_tag; + unsigned long irqflags; + struct sk_buff *skb; + + skb = hsr_init_skb(master, hsr_ver); + if (!skb) { + WARN_ONCE(1, "HSR: Could not send supervision frame\n"); + return; + } + if (hsr_ver > 0) { hsr_tag = skb_put(skb, sizeof(struct hsr_tag)); hsr_tag->encap_proto = htons(ETH_P_PRP); @@ -299,11 +317,8 @@ static void send_hsr_supervision_frame(struct hsr_port *master, return; hsr_forward_skb(skb, master); - return; -out: - WARN_ONCE(1, "HSR: Could not send supervision frame\n"); - kfree_skb(skb); + return; } /* Announce (supervision frame) timer function -- 2.17.1