18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci * Copyright (c) 2019, Vladimir Oltean <olteanv@gmail.com> 38c2ecf20Sopenharmony_ci */ 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci#ifndef _NET_DSA_8021Q_H 68c2ecf20Sopenharmony_ci#define _NET_DSA_8021Q_H 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#include <linux/refcount.h> 98c2ecf20Sopenharmony_ci#include <linux/types.h> 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_cistruct dsa_switch; 128c2ecf20Sopenharmony_cistruct sk_buff; 138c2ecf20Sopenharmony_cistruct net_device; 148c2ecf20Sopenharmony_cistruct packet_type; 158c2ecf20Sopenharmony_cistruct dsa_8021q_context; 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_cistruct dsa_8021q_crosschip_link { 188c2ecf20Sopenharmony_ci struct list_head list; 198c2ecf20Sopenharmony_ci int port; 208c2ecf20Sopenharmony_ci struct dsa_8021q_context *other_ctx; 218c2ecf20Sopenharmony_ci int other_port; 228c2ecf20Sopenharmony_ci refcount_t refcount; 238c2ecf20Sopenharmony_ci}; 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_cistruct dsa_8021q_ops { 268c2ecf20Sopenharmony_ci int (*vlan_add)(struct dsa_switch *ds, int port, u16 vid, u16 flags); 278c2ecf20Sopenharmony_ci int (*vlan_del)(struct dsa_switch *ds, int port, u16 vid); 288c2ecf20Sopenharmony_ci}; 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_cistruct dsa_8021q_context { 318c2ecf20Sopenharmony_ci const struct dsa_8021q_ops *ops; 328c2ecf20Sopenharmony_ci struct dsa_switch *ds; 338c2ecf20Sopenharmony_ci struct list_head crosschip_links; 348c2ecf20Sopenharmony_ci /* EtherType of RX VID, used for filtering on master interface */ 358c2ecf20Sopenharmony_ci __be16 proto; 368c2ecf20Sopenharmony_ci}; 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci#define DSA_8021Q_N_SUBVLAN 8 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci#if IS_ENABLED(CONFIG_NET_DSA_TAG_8021Q) 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ciint dsa_8021q_setup(struct dsa_8021q_context *ctx, bool enabled); 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ciint dsa_8021q_crosschip_bridge_join(struct dsa_8021q_context *ctx, int port, 458c2ecf20Sopenharmony_ci struct dsa_8021q_context *other_ctx, 468c2ecf20Sopenharmony_ci int other_port); 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ciint dsa_8021q_crosschip_bridge_leave(struct dsa_8021q_context *ctx, int port, 498c2ecf20Sopenharmony_ci struct dsa_8021q_context *other_ctx, 508c2ecf20Sopenharmony_ci int other_port); 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_cistruct sk_buff *dsa_8021q_xmit(struct sk_buff *skb, struct net_device *netdev, 538c2ecf20Sopenharmony_ci u16 tpid, u16 tci); 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ciu16 dsa_8021q_tx_vid(struct dsa_switch *ds, int port); 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ciu16 dsa_8021q_rx_vid(struct dsa_switch *ds, int port); 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ciu16 dsa_8021q_rx_vid_subvlan(struct dsa_switch *ds, int port, u16 subvlan); 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ciint dsa_8021q_rx_switch_id(u16 vid); 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ciint dsa_8021q_rx_source_port(u16 vid); 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ciu16 dsa_8021q_rx_subvlan(u16 vid); 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_cibool vid_is_dsa_8021q(u16 vid); 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci#else 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ciint dsa_8021q_setup(struct dsa_8021q_context *ctx, bool enabled) 728c2ecf20Sopenharmony_ci{ 738c2ecf20Sopenharmony_ci return 0; 748c2ecf20Sopenharmony_ci} 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ciint dsa_8021q_crosschip_bridge_join(struct dsa_8021q_context *ctx, int port, 778c2ecf20Sopenharmony_ci struct dsa_8021q_context *other_ctx, 788c2ecf20Sopenharmony_ci int other_port) 798c2ecf20Sopenharmony_ci{ 808c2ecf20Sopenharmony_ci return 0; 818c2ecf20Sopenharmony_ci} 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ciint dsa_8021q_crosschip_bridge_leave(struct dsa_8021q_context *ctx, int port, 848c2ecf20Sopenharmony_ci struct dsa_8021q_context *other_ctx, 858c2ecf20Sopenharmony_ci int other_port) 868c2ecf20Sopenharmony_ci{ 878c2ecf20Sopenharmony_ci return 0; 888c2ecf20Sopenharmony_ci} 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_cistruct sk_buff *dsa_8021q_xmit(struct sk_buff *skb, struct net_device *netdev, 918c2ecf20Sopenharmony_ci u16 tpid, u16 tci) 928c2ecf20Sopenharmony_ci{ 938c2ecf20Sopenharmony_ci return NULL; 948c2ecf20Sopenharmony_ci} 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_ciu16 dsa_8021q_tx_vid(struct dsa_switch *ds, int port) 978c2ecf20Sopenharmony_ci{ 988c2ecf20Sopenharmony_ci return 0; 998c2ecf20Sopenharmony_ci} 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_ciu16 dsa_8021q_rx_vid(struct dsa_switch *ds, int port) 1028c2ecf20Sopenharmony_ci{ 1038c2ecf20Sopenharmony_ci return 0; 1048c2ecf20Sopenharmony_ci} 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_ciu16 dsa_8021q_rx_vid_subvlan(struct dsa_switch *ds, int port, u16 subvlan) 1078c2ecf20Sopenharmony_ci{ 1088c2ecf20Sopenharmony_ci return 0; 1098c2ecf20Sopenharmony_ci} 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ciint dsa_8021q_rx_switch_id(u16 vid) 1128c2ecf20Sopenharmony_ci{ 1138c2ecf20Sopenharmony_ci return 0; 1148c2ecf20Sopenharmony_ci} 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_ciint dsa_8021q_rx_source_port(u16 vid) 1178c2ecf20Sopenharmony_ci{ 1188c2ecf20Sopenharmony_ci return 0; 1198c2ecf20Sopenharmony_ci} 1208c2ecf20Sopenharmony_ci 1218c2ecf20Sopenharmony_ciu16 dsa_8021q_rx_subvlan(u16 vid) 1228c2ecf20Sopenharmony_ci{ 1238c2ecf20Sopenharmony_ci return 0; 1248c2ecf20Sopenharmony_ci} 1258c2ecf20Sopenharmony_ci 1268c2ecf20Sopenharmony_cibool vid_is_dsa_8021q(u16 vid) 1278c2ecf20Sopenharmony_ci{ 1288c2ecf20Sopenharmony_ci return false; 1298c2ecf20Sopenharmony_ci} 1308c2ecf20Sopenharmony_ci 1318c2ecf20Sopenharmony_ci#endif /* IS_ENABLED(CONFIG_NET_DSA_TAG_8021Q) */ 1328c2ecf20Sopenharmony_ci 1338c2ecf20Sopenharmony_ci#endif /* _NET_DSA_8021Q_H */ 134