linux/net/dsa/tag_brcm.c

// SPDX-License-Identifier: GPL-2.0+
/*
 * Broadcom tag support
 *
 * Copyright (C) 2014 Broadcom Corporation
 */

#include <linux/dsa/brcm.h>
#include <linux/etherdevice.h>
#include <linux/if_vlan.h>
#include <linux/list.h>
#include <linux/slab.h>

#include "tag.h"

#define BRCM_NAME
#define BRCM_LEGACY_NAME
#define BRCM_PREPEND_NAME

/* Legacy Broadcom tag (6 bytes) */
#define BRCM_LEG_TAG_LEN

/* Type fields */
/* 1st byte in the tag */
#define BRCM_LEG_TYPE_HI
/* 2nd byte in the tag */
#define BRCM_LEG_TYPE_LO

/* Tag fields */
/* 3rd byte in the tag */
#define BRCM_LEG_UNICAST
#define BRCM_LEG_MULTICAST
#define BRCM_LEG_EGRESS
#define BRCM_LEG_INGRESS

/* 6th byte in the tag */
#define BRCM_LEG_PORT_ID

/* Newer Broadcom tag (4 bytes) */
#define BRCM_TAG_LEN

/* Tag is constructed and deconstructed using byte by byte access
 * because the tag is placed after the MAC Source Address, which does
 * not make it 4-bytes aligned, so this might cause unaligned accesses
 * on most systems where this is used.
 */

/* Ingress and egress opcodes */
#define BRCM_OPCODE_SHIFT
#define BRCM_OPCODE_MASK

/* Ingress fields */
/* 1st byte in the tag */
#define BRCM_IG_TC_SHIFT
#define BRCM_IG_TC_MASK
/* 2nd byte in the tag */
#define BRCM_IG_TE_MASK
#define BRCM_IG_TS_SHIFT
/* 3rd byte in the tag */
#define BRCM_IG_DSTMAP2_MASK
#define BRCM_IG_DSTMAP1_MASK

/* Egress fields */

/* 2nd byte in the tag */
#define BRCM_EG_CID_MASK

/* 3rd byte in the tag */
#define BRCM_EG_RC_MASK
#define BRCM_EG_RC_RSVD
#define BRCM_EG_RC_EXCEPTION
#define BRCM_EG_RC_PROT_SNOOP
#define BRCM_EG_RC_PROT_TERM
#define BRCM_EG_RC_SWITCH
#define BRCM_EG_RC_MAC_LEARN
#define BRCM_EG_RC_MIRROR
#define BRCM_EG_TC_SHIFT
#define BRCM_EG_TC_MASK
#define BRCM_EG_PID_MASK

#if IS_ENABLED(CONFIG_NET_DSA_TAG_BRCM) || \
	IS_ENABLED(CONFIG_NET_DSA_TAG_BRCM_PREPEND)

static struct sk_buff *brcm_tag_xmit_ll(struct sk_buff *skb,
					struct net_device *dev,
					unsigned int offset)
{}

/* Frames with this tag have one of these two layouts:
 * -----------------------------------
 * | MAC DA | MAC SA | 4b tag | Type | DSA_TAG_PROTO_BRCM
 * -----------------------------------
 * -----------------------------------
 * | 4b tag | MAC DA | MAC SA | Type | DSA_TAG_PROTO_BRCM_PREPEND
 * -----------------------------------
 * In both cases, at receive time, skb->data points 2 bytes before the actual
 * Ethernet type field and we have an offset of 4bytes between where skb->data
 * and where the payload starts. So the same low-level receive function can be
 * used.
 */
static struct sk_buff *brcm_tag_rcv_ll(struct sk_buff *skb,
				       struct net_device *dev,
				       unsigned int offset)
{}
#endif

#if IS_ENABLED(CONFIG_NET_DSA_TAG_BRCM)
static struct sk_buff *brcm_tag_xmit(struct sk_buff *skb,
				     struct net_device *dev)
{}


static struct sk_buff *brcm_tag_rcv(struct sk_buff *skb, struct net_device *dev)
{}

static const struct dsa_device_ops brcm_netdev_ops =;

DSA_TAG_DRIVER(brcm_netdev_ops);
MODULE_ALIAS_DSA_TAG_DRIVER();
#endif

#if IS_ENABLED(CONFIG_NET_DSA_TAG_BRCM_LEGACY)
static struct sk_buff *brcm_leg_tag_xmit(struct sk_buff *skb,
					 struct net_device *dev)
{}

static struct sk_buff *brcm_leg_tag_rcv(struct sk_buff *skb,
					struct net_device *dev)
{}

static const struct dsa_device_ops brcm_legacy_netdev_ops =;

DSA_TAG_DRIVER(brcm_legacy_netdev_ops);
MODULE_ALIAS_DSA_TAG_DRIVER();
#endif /* CONFIG_NET_DSA_TAG_BRCM_LEGACY */

#if IS_ENABLED(CONFIG_NET_DSA_TAG_BRCM_PREPEND)
static struct sk_buff *brcm_tag_xmit_prepend(struct sk_buff *skb,
					     struct net_device *dev)
{}

static struct sk_buff *brcm_tag_rcv_prepend(struct sk_buff *skb,
					    struct net_device *dev)
{}

static const struct dsa_device_ops brcm_prepend_netdev_ops =;

DSA_TAG_DRIVER(brcm_prepend_netdev_ops);
MODULE_ALIAS_DSA_TAG_DRIVER();
#endif

static struct dsa_tag_driver *dsa_tag_driver_array[] =;

module_dsa_tag_drivers(dsa_tag_driver_array);

MODULE_DESCRIPTION();
MODULE_LICENSE();