xref: /openbmc/linux/drivers/infiniband/ulp/opa_vnic/opa_vnic_internal.h (revision ead5d1f4d877e92c051e1a1ade623d0d30e71619)
17d6f728cSVishwanathapura, Niranjana #ifndef _OPA_VNIC_INTERNAL_H
27d6f728cSVishwanathapura, Niranjana #define _OPA_VNIC_INTERNAL_H
37d6f728cSVishwanathapura, Niranjana /*
47d6f728cSVishwanathapura, Niranjana  * Copyright(c) 2017 Intel Corporation.
57d6f728cSVishwanathapura, Niranjana  *
67d6f728cSVishwanathapura, Niranjana  * This file is provided under a dual BSD/GPLv2 license.  When using or
77d6f728cSVishwanathapura, Niranjana  * redistributing this file, you may do so under either license.
87d6f728cSVishwanathapura, Niranjana  *
97d6f728cSVishwanathapura, Niranjana  * GPL LICENSE SUMMARY
107d6f728cSVishwanathapura, Niranjana  *
117d6f728cSVishwanathapura, Niranjana  * This program is free software; you can redistribute it and/or modify
127d6f728cSVishwanathapura, Niranjana  * it under the terms of version 2 of the GNU General Public License as
137d6f728cSVishwanathapura, Niranjana  * published by the Free Software Foundation.
147d6f728cSVishwanathapura, Niranjana  *
157d6f728cSVishwanathapura, Niranjana  * This program is distributed in the hope that it will be useful, but
167d6f728cSVishwanathapura, Niranjana  * WITHOUT ANY WARRANTY; without even the implied warranty of
177d6f728cSVishwanathapura, Niranjana  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
187d6f728cSVishwanathapura, Niranjana  * General Public License for more details.
197d6f728cSVishwanathapura, Niranjana  *
207d6f728cSVishwanathapura, Niranjana  * BSD LICENSE
217d6f728cSVishwanathapura, Niranjana  *
227d6f728cSVishwanathapura, Niranjana  * Redistribution and use in source and binary forms, with or without
237d6f728cSVishwanathapura, Niranjana  * modification, are permitted provided that the following conditions
247d6f728cSVishwanathapura, Niranjana  * are met:
257d6f728cSVishwanathapura, Niranjana  *
267d6f728cSVishwanathapura, Niranjana  *  - Redistributions of source code must retain the above copyright
277d6f728cSVishwanathapura, Niranjana  *    notice, this list of conditions and the following disclaimer.
287d6f728cSVishwanathapura, Niranjana  *  - Redistributions in binary form must reproduce the above copyright
297d6f728cSVishwanathapura, Niranjana  *    notice, this list of conditions and the following disclaimer in
307d6f728cSVishwanathapura, Niranjana  *    the documentation and/or other materials provided with the
317d6f728cSVishwanathapura, Niranjana  *    distribution.
327d6f728cSVishwanathapura, Niranjana  *  - Neither the name of Intel Corporation nor the names of its
337d6f728cSVishwanathapura, Niranjana  *    contributors may be used to endorse or promote products derived
347d6f728cSVishwanathapura, Niranjana  *    from this software without specific prior written permission.
357d6f728cSVishwanathapura, Niranjana  *
367d6f728cSVishwanathapura, Niranjana  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
377d6f728cSVishwanathapura, Niranjana  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
387d6f728cSVishwanathapura, Niranjana  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
397d6f728cSVishwanathapura, Niranjana  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
407d6f728cSVishwanathapura, Niranjana  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
417d6f728cSVishwanathapura, Niranjana  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
427d6f728cSVishwanathapura, Niranjana  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
437d6f728cSVishwanathapura, Niranjana  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
447d6f728cSVishwanathapura, Niranjana  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
457d6f728cSVishwanathapura, Niranjana  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
467d6f728cSVishwanathapura, Niranjana  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
477d6f728cSVishwanathapura, Niranjana  *
487d6f728cSVishwanathapura, Niranjana  */
497d6f728cSVishwanathapura, Niranjana 
507d6f728cSVishwanathapura, Niranjana /*
517d6f728cSVishwanathapura, Niranjana  * This file contains OPA VNIC driver internal declarations
527d6f728cSVishwanathapura, Niranjana  */
537d6f728cSVishwanathapura, Niranjana 
547d6f728cSVishwanathapura, Niranjana #include <linux/bitops.h>
557d6f728cSVishwanathapura, Niranjana #include <linux/etherdevice.h>
567d6f728cSVishwanathapura, Niranjana #include <linux/hashtable.h>
577d6f728cSVishwanathapura, Niranjana #include <linux/sizes.h>
587d6f728cSVishwanathapura, Niranjana #include <rdma/opa_vnic.h>
597d6f728cSVishwanathapura, Niranjana 
607d6f728cSVishwanathapura, Niranjana #include "opa_vnic_encap.h"
617d6f728cSVishwanathapura, Niranjana 
627d6f728cSVishwanathapura, Niranjana #define OPA_VNIC_VLAN_PCP(vlan_tci)  \
637d6f728cSVishwanathapura, Niranjana 			(((vlan_tci) & VLAN_PRIO_MASK) >> VLAN_PRIO_SHIFT)
647d6f728cSVishwanathapura, Niranjana 
657d6f728cSVishwanathapura, Niranjana /* Flow to default port redirection table size */
667d6f728cSVishwanathapura, Niranjana #define OPA_VNIC_FLOW_TBL_SIZE    32
677d6f728cSVishwanathapura, Niranjana 
687d6f728cSVishwanathapura, Niranjana /* Invalid port number */
697d6f728cSVishwanathapura, Niranjana #define OPA_VNIC_INVALID_PORT     0xff
707d6f728cSVishwanathapura, Niranjana 
717d6f728cSVishwanathapura, Niranjana struct opa_vnic_adapter;
727d6f728cSVishwanathapura, Niranjana 
73*dfa4344dSrd.dunlab@gmail.com /*
747d6f728cSVishwanathapura, Niranjana  * struct __opa_vesw_info - OPA vnic virtual switch info
7572dc7614SVishwanathapura, Niranjana  *
7672dc7614SVishwanathapura, Niranjana  * Same as opa_vesw_info without bitwise attribute.
777d6f728cSVishwanathapura, Niranjana  */
787d6f728cSVishwanathapura, Niranjana struct __opa_vesw_info {
797d6f728cSVishwanathapura, Niranjana 	u16  fabric_id;
807d6f728cSVishwanathapura, Niranjana 	u16  vesw_id;
817d6f728cSVishwanathapura, Niranjana 
827d6f728cSVishwanathapura, Niranjana 	u8   rsvd0[6];
837d6f728cSVishwanathapura, Niranjana 	u16  def_port_mask;
847d6f728cSVishwanathapura, Niranjana 
857d6f728cSVishwanathapura, Niranjana 	u8   rsvd1[2];
867d6f728cSVishwanathapura, Niranjana 	u16  pkey;
877d6f728cSVishwanathapura, Niranjana 
887d6f728cSVishwanathapura, Niranjana 	u8   rsvd2[4];
897d6f728cSVishwanathapura, Niranjana 	u32  u_mcast_dlid;
907d6f728cSVishwanathapura, Niranjana 	u32  u_ucast_dlid[OPA_VESW_MAX_NUM_DEF_PORT];
917d6f728cSVishwanathapura, Niranjana 
92b209a368SNiranjana Vishwanathapura 	u32  rc;
93b209a368SNiranjana Vishwanathapura 
94b209a368SNiranjana Vishwanathapura 	u8   rsvd3[56];
9562f1e84eSNiranjana Vishwanathapura 	u16  eth_mtu;
967d6f728cSVishwanathapura, Niranjana 	u8   rsvd4[2];
977d6f728cSVishwanathapura, Niranjana } __packed;
987d6f728cSVishwanathapura, Niranjana 
99*dfa4344dSrd.dunlab@gmail.com /*
1007d6f728cSVishwanathapura, Niranjana  * struct __opa_per_veswport_info - OPA vnic per port info
10172dc7614SVishwanathapura, Niranjana  *
10272dc7614SVishwanathapura, Niranjana  * Same as opa_per_veswport_info without bitwise attribute.
1037d6f728cSVishwanathapura, Niranjana  */
1047d6f728cSVishwanathapura, Niranjana struct __opa_per_veswport_info {
1057d6f728cSVishwanathapura, Niranjana 	u32  port_num;
1067d6f728cSVishwanathapura, Niranjana 
1077d6f728cSVishwanathapura, Niranjana 	u8   eth_link_status;
1087d6f728cSVishwanathapura, Niranjana 	u8   rsvd0[3];
1097d6f728cSVishwanathapura, Niranjana 
1107d6f728cSVishwanathapura, Niranjana 	u8   base_mac_addr[ETH_ALEN];
1117d6f728cSVishwanathapura, Niranjana 	u8   config_state;
1127d6f728cSVishwanathapura, Niranjana 	u8   oper_state;
1137d6f728cSVishwanathapura, Niranjana 
1147d6f728cSVishwanathapura, Niranjana 	u16  max_mac_tbl_ent;
1157d6f728cSVishwanathapura, Niranjana 	u16  max_smac_ent;
1167d6f728cSVishwanathapura, Niranjana 	u32  mac_tbl_digest;
1177d6f728cSVishwanathapura, Niranjana 	u8   rsvd1[4];
1187d6f728cSVishwanathapura, Niranjana 
1197d6f728cSVishwanathapura, Niranjana 	u32  encap_slid;
1207d6f728cSVishwanathapura, Niranjana 
1217d6f728cSVishwanathapura, Niranjana 	u8   pcp_to_sc_uc[OPA_VNIC_MAX_NUM_PCP];
1227d6f728cSVishwanathapura, Niranjana 	u8   pcp_to_vl_uc[OPA_VNIC_MAX_NUM_PCP];
1237d6f728cSVishwanathapura, Niranjana 	u8   pcp_to_sc_mc[OPA_VNIC_MAX_NUM_PCP];
1247d6f728cSVishwanathapura, Niranjana 	u8   pcp_to_vl_mc[OPA_VNIC_MAX_NUM_PCP];
1257d6f728cSVishwanathapura, Niranjana 
1267d6f728cSVishwanathapura, Niranjana 	u8   non_vlan_sc_uc;
1277d6f728cSVishwanathapura, Niranjana 	u8   non_vlan_vl_uc;
1287d6f728cSVishwanathapura, Niranjana 	u8   non_vlan_sc_mc;
1297d6f728cSVishwanathapura, Niranjana 	u8   non_vlan_vl_mc;
1307d6f728cSVishwanathapura, Niranjana 
1317d6f728cSVishwanathapura, Niranjana 	u8   rsvd2[48];
1327d6f728cSVishwanathapura, Niranjana 
1337d6f728cSVishwanathapura, Niranjana 	u16  uc_macs_gen_count;
1347d6f728cSVishwanathapura, Niranjana 	u16  mc_macs_gen_count;
1357d6f728cSVishwanathapura, Niranjana 
1367d6f728cSVishwanathapura, Niranjana 	u8   rsvd3[8];
1377d6f728cSVishwanathapura, Niranjana } __packed;
1387d6f728cSVishwanathapura, Niranjana 
139*dfa4344dSrd.dunlab@gmail.com /*
1407d6f728cSVishwanathapura, Niranjana  * struct __opa_veswport_info - OPA vnic port info
14172dc7614SVishwanathapura, Niranjana  *
14272dc7614SVishwanathapura, Niranjana  * Same as opa_veswport_info without bitwise attribute.
1437d6f728cSVishwanathapura, Niranjana  */
1447d6f728cSVishwanathapura, Niranjana struct __opa_veswport_info {
1457d6f728cSVishwanathapura, Niranjana 	struct __opa_vesw_info            vesw;
1467d6f728cSVishwanathapura, Niranjana 	struct __opa_per_veswport_info    vport;
1477d6f728cSVishwanathapura, Niranjana };
1487d6f728cSVishwanathapura, Niranjana 
149*dfa4344dSrd.dunlab@gmail.com /*
15072dc7614SVishwanathapura, Niranjana  * struct __opa_veswport_trap - OPA vnic trap info
15172dc7614SVishwanathapura, Niranjana  *
15272dc7614SVishwanathapura, Niranjana  * Same as opa_veswport_trap without bitwise attribute.
15372dc7614SVishwanathapura, Niranjana  */
15472dc7614SVishwanathapura, Niranjana struct __opa_veswport_trap {
15572dc7614SVishwanathapura, Niranjana 	u16	fabric_id;
15672dc7614SVishwanathapura, Niranjana 	u16	veswid;
15772dc7614SVishwanathapura, Niranjana 	u32	veswportnum;
15872dc7614SVishwanathapura, Niranjana 	u16	opaportnum;
15972dc7614SVishwanathapura, Niranjana 	u8	veswportindex;
16072dc7614SVishwanathapura, Niranjana 	u8	opcode;
16172dc7614SVishwanathapura, Niranjana 	u32	reserved;
16272dc7614SVishwanathapura, Niranjana } __packed;
16372dc7614SVishwanathapura, Niranjana 
16472dc7614SVishwanathapura, Niranjana /**
165cfd34f8eSVishwanathapura, Niranjana  * struct opa_vnic_ctrl_port - OPA virtual NIC control port
166cfd34f8eSVishwanathapura, Niranjana  * @ibdev: pointer to ib device
167cfd34f8eSVishwanathapura, Niranjana  * @ops: opa vnic control operations
1681bd671abSVishwanathapura, Niranjana  * @num_ports: number of opa ports
169cfd34f8eSVishwanathapura, Niranjana  */
170cfd34f8eSVishwanathapura, Niranjana struct opa_vnic_ctrl_port {
171cfd34f8eSVishwanathapura, Niranjana 	struct ib_device           *ibdev;
172cfd34f8eSVishwanathapura, Niranjana 	struct opa_vnic_ctrl_ops   *ops;
1731bd671abSVishwanathapura, Niranjana 	u8                          num_ports;
174cfd34f8eSVishwanathapura, Niranjana };
175cfd34f8eSVishwanathapura, Niranjana 
176cfd34f8eSVishwanathapura, Niranjana /**
1777d6f728cSVishwanathapura, Niranjana  * struct opa_vnic_adapter - OPA VNIC netdev private data structure
1787d6f728cSVishwanathapura, Niranjana  * @netdev: pointer to associated netdev
1797d6f728cSVishwanathapura, Niranjana  * @ibdev: ib device
180cfd34f8eSVishwanathapura, Niranjana  * @cport: pointer to opa vnic control port
1817d6f728cSVishwanathapura, Niranjana  * @rn_ops: rdma netdev's net_device_ops
1827d6f728cSVishwanathapura, Niranjana  * @port_num: OPA port number
1837d6f728cSVishwanathapura, Niranjana  * @vport_num: vesw port number
1847d6f728cSVishwanathapura, Niranjana  * @lock: adapter lock
1857d6f728cSVishwanathapura, Niranjana  * @info: virtual ethernet switch port information
186cfd34f8eSVishwanathapura, Niranjana  * @vema_mac_addr: mac address configured by vema
187cfd34f8eSVishwanathapura, Niranjana  * @umac_hash: unicast maclist hash
188cfd34f8eSVishwanathapura, Niranjana  * @mmac_hash: multicast maclist hash
189174e03d7SVishwanathapura, Niranjana  * @mactbl: hash table of MAC entries
190174e03d7SVishwanathapura, Niranjana  * @mactbl_lock: mac table lock
191009b7dd4SVishwanathapura, Niranjana  * @stats_lock: statistics lock
1927d6f728cSVishwanathapura, Niranjana  * @flow_tbl: flow to default port redirection table
1931bd671abSVishwanathapura, Niranjana  * @trap_timeout: trap timeout
1941bd671abSVishwanathapura, Niranjana  * @trap_count: no. of traps allowed within timeout period
1957d6f728cSVishwanathapura, Niranjana  */
1967d6f728cSVishwanathapura, Niranjana struct opa_vnic_adapter {
1977d6f728cSVishwanathapura, Niranjana 	struct net_device             *netdev;
1987d6f728cSVishwanathapura, Niranjana 	struct ib_device              *ibdev;
199cfd34f8eSVishwanathapura, Niranjana 	struct opa_vnic_ctrl_port     *cport;
2007d6f728cSVishwanathapura, Niranjana 	const struct net_device_ops   *rn_ops;
2017d6f728cSVishwanathapura, Niranjana 
2027d6f728cSVishwanathapura, Niranjana 	u8 port_num;
2037d6f728cSVishwanathapura, Niranjana 	u8 vport_num;
2047d6f728cSVishwanathapura, Niranjana 
2057d6f728cSVishwanathapura, Niranjana 	/* Lock used around concurrent updates to netdev */
2067d6f728cSVishwanathapura, Niranjana 	struct mutex lock;
2077d6f728cSVishwanathapura, Niranjana 
2087d6f728cSVishwanathapura, Niranjana 	struct __opa_veswport_info  info;
209cfd34f8eSVishwanathapura, Niranjana 	u8                          vema_mac_addr[ETH_ALEN];
210cfd34f8eSVishwanathapura, Niranjana 	u32                         umac_hash;
211cfd34f8eSVishwanathapura, Niranjana 	u32                         mmac_hash;
212174e03d7SVishwanathapura, Niranjana 	struct hlist_head  __rcu   *mactbl;
213174e03d7SVishwanathapura, Niranjana 
214174e03d7SVishwanathapura, Niranjana 	/* Lock used to protect updates to mac table */
215174e03d7SVishwanathapura, Niranjana 	struct mutex mactbl_lock;
2167d6f728cSVishwanathapura, Niranjana 
217009b7dd4SVishwanathapura, Niranjana 	/* Lock used to protect access to vnic counters */
218a379d69fSVishwanathapura, Niranjana 	spinlock_t stats_lock;
219009b7dd4SVishwanathapura, Niranjana 
2207d6f728cSVishwanathapura, Niranjana 	u8 flow_tbl[OPA_VNIC_FLOW_TBL_SIZE];
2211bd671abSVishwanathapura, Niranjana 
2221bd671abSVishwanathapura, Niranjana 	unsigned long trap_timeout;
2231bd671abSVishwanathapura, Niranjana 	u8            trap_count;
2247d6f728cSVishwanathapura, Niranjana };
2257d6f728cSVishwanathapura, Niranjana 
226174e03d7SVishwanathapura, Niranjana /* Same as opa_veswport_mactable_entry, but without bitwise attribute */
227174e03d7SVishwanathapura, Niranjana struct __opa_vnic_mactable_entry {
228174e03d7SVishwanathapura, Niranjana 	u8  mac_addr[ETH_ALEN];
229174e03d7SVishwanathapura, Niranjana 	u8  mac_addr_mask[ETH_ALEN];
230174e03d7SVishwanathapura, Niranjana 	u32 dlid_sd;
231174e03d7SVishwanathapura, Niranjana } __packed;
232174e03d7SVishwanathapura, Niranjana 
233174e03d7SVishwanathapura, Niranjana /**
234174e03d7SVishwanathapura, Niranjana  * struct opa_vnic_mac_tbl_node - OPA VNIC mac table node
235174e03d7SVishwanathapura, Niranjana  * @hlist: hash list handle
236174e03d7SVishwanathapura, Niranjana  * @index: index of entry in the mac table
237174e03d7SVishwanathapura, Niranjana  * @entry: entry in the table
238174e03d7SVishwanathapura, Niranjana  */
239174e03d7SVishwanathapura, Niranjana struct opa_vnic_mac_tbl_node {
240174e03d7SVishwanathapura, Niranjana 	struct hlist_node                    hlist;
241174e03d7SVishwanathapura, Niranjana 	u16                                  index;
242174e03d7SVishwanathapura, Niranjana 	struct __opa_vnic_mactable_entry     entry;
243174e03d7SVishwanathapura, Niranjana };
244174e03d7SVishwanathapura, Niranjana 
2457d6f728cSVishwanathapura, Niranjana #define v_dbg(format, arg...) \
2467d6f728cSVishwanathapura, Niranjana 	netdev_dbg(adapter->netdev, format, ## arg)
2477d6f728cSVishwanathapura, Niranjana #define v_err(format, arg...) \
2487d6f728cSVishwanathapura, Niranjana 	netdev_err(adapter->netdev, format, ## arg)
2497d6f728cSVishwanathapura, Niranjana #define v_info(format, arg...) \
2507d6f728cSVishwanathapura, Niranjana 	netdev_info(adapter->netdev, format, ## arg)
2517d6f728cSVishwanathapura, Niranjana #define v_warn(format, arg...) \
2527d6f728cSVishwanathapura, Niranjana 	netdev_warn(adapter->netdev, format, ## arg)
2537d6f728cSVishwanathapura, Niranjana 
254cfd34f8eSVishwanathapura, Niranjana #define c_err(format, arg...) \
255cfd34f8eSVishwanathapura, Niranjana 	dev_err(&cport->ibdev->dev, format, ## arg)
256cfd34f8eSVishwanathapura, Niranjana #define c_info(format, arg...) \
257cfd34f8eSVishwanathapura, Niranjana 	dev_info(&cport->ibdev->dev, format, ## arg)
2581bd671abSVishwanathapura, Niranjana #define c_dbg(format, arg...) \
2591bd671abSVishwanathapura, Niranjana 	dev_dbg(&cport->ibdev->dev, format, ## arg)
260cfd34f8eSVishwanathapura, Niranjana 
26172dc7614SVishwanathapura, Niranjana /* The maximum allowed entries in the mac table */
26272dc7614SVishwanathapura, Niranjana #define OPA_VNIC_MAC_TBL_MAX_ENTRIES  2048
26372dc7614SVishwanathapura, Niranjana /* Limit of smac entries in mac table */
26472dc7614SVishwanathapura, Niranjana #define OPA_VNIC_MAX_SMAC_LIMIT       256
26572dc7614SVishwanathapura, Niranjana 
26672dc7614SVishwanathapura, Niranjana /* The last octet of the MAC address is used as the key to the hash table */
26772dc7614SVishwanathapura, Niranjana #define OPA_VNIC_MAC_HASH_IDX         5
26872dc7614SVishwanathapura, Niranjana 
26972dc7614SVishwanathapura, Niranjana /* The VNIC MAC hash table is of size 2^8 */
27072dc7614SVishwanathapura, Niranjana #define OPA_VNIC_MAC_TBL_HASH_BITS    8
27172dc7614SVishwanathapura, Niranjana #define OPA_VNIC_MAC_TBL_SIZE  BIT(OPA_VNIC_MAC_TBL_HASH_BITS)
27272dc7614SVishwanathapura, Niranjana 
273174e03d7SVishwanathapura, Niranjana /* VNIC HASH MACROS */
274174e03d7SVishwanathapura, Niranjana #define vnic_hash_init(hashtable) __hash_init(hashtable, OPA_VNIC_MAC_TBL_SIZE)
275174e03d7SVishwanathapura, Niranjana 
276174e03d7SVishwanathapura, Niranjana #define vnic_hash_add(hashtable, node, key)                                   \
277174e03d7SVishwanathapura, Niranjana 	hlist_add_head(node,                                                  \
278174e03d7SVishwanathapura, Niranjana 		&hashtable[hash_min(key, ilog2(OPA_VNIC_MAC_TBL_SIZE))])
279174e03d7SVishwanathapura, Niranjana 
280174e03d7SVishwanathapura, Niranjana #define vnic_hash_for_each_safe(name, bkt, tmp, obj, member)                  \
281174e03d7SVishwanathapura, Niranjana 	for ((bkt) = 0, obj = NULL;                                           \
282174e03d7SVishwanathapura, Niranjana 		    !obj && (bkt) < OPA_VNIC_MAC_TBL_SIZE; (bkt)++)           \
283174e03d7SVishwanathapura, Niranjana 		hlist_for_each_entry_safe(obj, tmp, &name[bkt], member)
284174e03d7SVishwanathapura, Niranjana 
285174e03d7SVishwanathapura, Niranjana #define vnic_hash_for_each_possible(name, obj, member, key)                   \
286174e03d7SVishwanathapura, Niranjana 	hlist_for_each_entry(obj,                                             \
287174e03d7SVishwanathapura, Niranjana 		&name[hash_min(key, ilog2(OPA_VNIC_MAC_TBL_SIZE))], member)
288174e03d7SVishwanathapura, Niranjana 
289174e03d7SVishwanathapura, Niranjana #define vnic_hash_for_each(name, bkt, obj, member)                            \
290174e03d7SVishwanathapura, Niranjana 	for ((bkt) = 0, obj = NULL;                                           \
291174e03d7SVishwanathapura, Niranjana 		    !obj && (bkt) < OPA_VNIC_MAC_TBL_SIZE; (bkt)++)           \
292174e03d7SVishwanathapura, Niranjana 		hlist_for_each_entry(obj, &name[bkt], member)
293174e03d7SVishwanathapura, Niranjana 
2941bd671abSVishwanathapura, Niranjana extern char opa_vnic_driver_name[];
2951bd671abSVishwanathapura, Niranjana 
2967d6f728cSVishwanathapura, Niranjana struct opa_vnic_adapter *opa_vnic_add_netdev(struct ib_device *ibdev,
2977d6f728cSVishwanathapura, Niranjana 					     u8 port_num, u8 vport_num);
2987d6f728cSVishwanathapura, Niranjana void opa_vnic_rem_netdev(struct opa_vnic_adapter *adapter);
2997d6f728cSVishwanathapura, Niranjana void opa_vnic_encap_skb(struct opa_vnic_adapter *adapter, struct sk_buff *skb);
3007d6f728cSVishwanathapura, Niranjana u8 opa_vnic_get_vl(struct opa_vnic_adapter *adapter, struct sk_buff *skb);
301d80d8d55SAlexander Duyck u8 opa_vnic_calc_entropy(struct sk_buff *skb);
302cfd34f8eSVishwanathapura, Niranjana void opa_vnic_process_vema_config(struct opa_vnic_adapter *adapter);
303174e03d7SVishwanathapura, Niranjana void opa_vnic_release_mac_tbl(struct opa_vnic_adapter *adapter);
304174e03d7SVishwanathapura, Niranjana void opa_vnic_query_mac_tbl(struct opa_vnic_adapter *adapter,
305174e03d7SVishwanathapura, Niranjana 			    struct opa_veswport_mactable *tbl);
306174e03d7SVishwanathapura, Niranjana int opa_vnic_update_mac_tbl(struct opa_vnic_adapter *adapter,
307174e03d7SVishwanathapura, Niranjana 			    struct opa_veswport_mactable *tbl);
308cfd34f8eSVishwanathapura, Niranjana void opa_vnic_query_ucast_macs(struct opa_vnic_adapter *adapter,
309cfd34f8eSVishwanathapura, Niranjana 			       struct opa_veswport_iface_macs *macs);
310cfd34f8eSVishwanathapura, Niranjana void opa_vnic_query_mcast_macs(struct opa_vnic_adapter *adapter,
311cfd34f8eSVishwanathapura, Niranjana 			       struct opa_veswport_iface_macs *macs);
312cfd34f8eSVishwanathapura, Niranjana void opa_vnic_get_summary_counters(struct opa_vnic_adapter *adapter,
313cfd34f8eSVishwanathapura, Niranjana 				   struct opa_veswport_summary_counters *cntrs);
314cfd34f8eSVishwanathapura, Niranjana void opa_vnic_get_error_counters(struct opa_vnic_adapter *adapter,
315cfd34f8eSVishwanathapura, Niranjana 				 struct opa_veswport_error_counters *cntrs);
316cfd34f8eSVishwanathapura, Niranjana void opa_vnic_get_vesw_info(struct opa_vnic_adapter *adapter,
317cfd34f8eSVishwanathapura, Niranjana 			    struct opa_vesw_info *info);
318cfd34f8eSVishwanathapura, Niranjana void opa_vnic_set_vesw_info(struct opa_vnic_adapter *adapter,
319cfd34f8eSVishwanathapura, Niranjana 			    struct opa_vesw_info *info);
320cfd34f8eSVishwanathapura, Niranjana void opa_vnic_get_per_veswport_info(struct opa_vnic_adapter *adapter,
321cfd34f8eSVishwanathapura, Niranjana 				    struct opa_per_veswport_info *info);
322cfd34f8eSVishwanathapura, Niranjana void opa_vnic_set_per_veswport_info(struct opa_vnic_adapter *adapter,
323cfd34f8eSVishwanathapura, Niranjana 				    struct opa_per_veswport_info *info);
324cfd34f8eSVishwanathapura, Niranjana void opa_vnic_vema_report_event(struct opa_vnic_adapter *adapter, u8 event);
3257d6f728cSVishwanathapura, Niranjana void opa_vnic_set_ethtool_ops(struct net_device *netdev);
3261bd671abSVishwanathapura, Niranjana void opa_vnic_vema_send_trap(struct opa_vnic_adapter *adapter,
3271bd671abSVishwanathapura, Niranjana 			     struct __opa_veswport_trap *data, u32 lid);
3287d6f728cSVishwanathapura, Niranjana 
3297d6f728cSVishwanathapura, Niranjana #endif /* _OPA_VNIC_INTERNAL_H */
330