~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/net/dsa/tag_trailer.c

Version: ~ [ linux-5.15-rc5 ] ~ [ linux-5.14.11 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.72 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.152 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.210 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.250 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.286 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.288 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.18.140 ] ~ [ linux-3.16.85 ] ~ [ linux-3.14.79 ] ~ [ linux-3.12.74 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0+
  2 /*
  3  * net/dsa/tag_trailer.c - Trailer tag format handling
  4  * Copyright (c) 2008-2009 Marvell Semiconductor
  5  */
  6 
  7 #include <linux/etherdevice.h>
  8 #include <linux/list.h>
  9 #include <linux/slab.h>
 10 
 11 #include "dsa_priv.h"
 12 
 13 static struct sk_buff *trailer_xmit(struct sk_buff *skb, struct net_device *dev)
 14 {
 15         struct dsa_port *dp = dsa_slave_to_port(dev);
 16         u8 *trailer;
 17 
 18         trailer = skb_put(skb, 4);
 19         trailer[0] = 0x80;
 20         trailer[1] = 1 << dp->index;
 21         trailer[2] = 0x10;
 22         trailer[3] = 0x00;
 23 
 24         return skb;
 25 }
 26 
 27 static struct sk_buff *trailer_rcv(struct sk_buff *skb, struct net_device *dev,
 28                                    struct packet_type *pt)
 29 {
 30         u8 *trailer;
 31         int source_port;
 32 
 33         if (skb_linearize(skb))
 34                 return NULL;
 35 
 36         trailer = skb_tail_pointer(skb) - 4;
 37         if (trailer[0] != 0x80 || (trailer[1] & 0xf8) != 0x00 ||
 38             (trailer[2] & 0xef) != 0x00 || trailer[3] != 0x00)
 39                 return NULL;
 40 
 41         source_port = trailer[1] & 7;
 42 
 43         skb->dev = dsa_master_find_slave(dev, 0, source_port);
 44         if (!skb->dev)
 45                 return NULL;
 46 
 47         if (pskb_trim_rcsum(skb, skb->len - 4))
 48                 return NULL;
 49 
 50         return skb;
 51 }
 52 
 53 static const struct dsa_device_ops trailer_netdev_ops = {
 54         .name   = "trailer",
 55         .proto  = DSA_TAG_PROTO_TRAILER,
 56         .xmit   = trailer_xmit,
 57         .rcv    = trailer_rcv,
 58         .overhead = 4,
 59         .tail_tag = true,
 60 };
 61 
 62 MODULE_LICENSE("GPL");
 63 MODULE_ALIAS_DSA_TAG_DRIVER(DSA_TAG_PROTO_TRAILER);
 64 
 65 module_dsa_tag_driver(trailer_netdev_ops);
 66 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp