/* * This file is part of the Chelsio T4 PCI-E SR-IOV Virtual Function Ethernet * driver for Linux. * * Copyright (c) 2009-2010 Chelsio Communications, Inc. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU * General Public License (GPL) Version 2, available from the file * COPYING in the main directory of this source tree, or the * OpenIB.org BSD license below: * * Redistribution and use in source and binary forms, with or * without modification, are permitted provided that the following * conditions are met: * * - Redistributions of source code must retain the above * copyright notice, this list of conditions and the following * disclaimer. * * - Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials * provided with the distribution. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ /* * This file should not be included directly. Include t4vf_common.h instead. */ #ifndef __CXGB4VF_ADAPTER_H__ #define __CXGB4VF_ADAPTER_H__ #include <linux/etherdevice.h> #include <linux/interrupt.h> #include <linux/pci.h> #include <linux/spinlock.h> #include <linux/skbuff.h> #include <linux/if_ether.h> #include <linux/netdevice.h> #include "../cxgb4/t4_hw.h" /* * Constants of the implementation. */ enum { … }; /* * Forward structure definition references. */ struct adapter; struct sge_eth_rxq; struct sge_rspq; /* * Per-"port" information. This is really per-Virtual Interface information * but the use of the "port" nomanclature makes it easier to go back and forth * between the PF and VF drivers ... */ struct port_info { … }; /* * Scatter Gather Engine resources for the "adapter". Our ingress and egress * queues are organized into "Queue Sets" with one ingress and one egress * queue per Queue Set. These Queue Sets are aportionable between the "ports" * (Virtual Interfaces). One extra ingress queue is used to receive * asynchronous messages from the firmware. Note that the "Queue IDs" that we * use here are really "Relative Queue IDs" which are returned as part of the * firmware command to allocate queues. These queue IDs are relative to the * absolute Queue ID base of the section of the Queue ID space allocated to * the PF/VF. */ /* * SGE free-list queue state. */ struct rx_sw_desc; struct sge_fl { … }; /* * An ingress packet gather list. */ struct pkt_gl { … }; rspq_handler_t; /* * State for an SGE Response Queue. */ struct sge_rspq { … }; /* * Ethernet queue statistics */ struct sge_eth_stats { … }; /* * State for an Ethernet Receive Queue. */ struct sge_eth_rxq { … }; /* * SGE Transmit Queue state. This contains all of the resources associated * with the hardware status of a TX Queue which is a circular ring of hardware * TX Descriptors. For convenience, it also contains a pointer to a parallel * "Software Descriptor" array but we don't know anything about it here other * than its type name. */ struct tx_desc { … }; struct tx_sw_desc; struct sge_txq { … }; /* * State for an Ethernet Transmit Queue. */ struct sge_eth_txq { … }; /* * The complete set of Scatter/Gather Engine resources. */ struct sge { … }; /* * Utility macros to convert Absolute- to Relative-Queue indices and Egress- * and Ingress-Queues. The EQ_MAP() and IQ_MAP() macros which provide * pointers to Ingress- and Egress-Queues can be used as both L- and R-values */ #define EQ_IDX(s, abs_id) … #define IQ_IDX(s, abs_id) … #define EQ_MAP(s, abs_id) … #define IQ_MAP(s, abs_id) … /* * Macro to iterate across Queue Sets ("rxq" is a historic misnomer). */ #define for_each_ethrxq(sge, iter) … struct hash_mac_addr { … }; struct mbox_list { … }; /* * Per-"adapter" (Virtual Function) information. */ struct adapter { … }; enum { … }; /* * The following register read/write routine definitions are required by * the common code. */ /** * t4_read_reg - read a HW register * @adapter: the adapter * @reg_addr: the register address * * Returns the 32-bit value of the given HW register. */ static inline u32 t4_read_reg(struct adapter *adapter, u32 reg_addr) { … } /** * t4_write_reg - write a HW register * @adapter: the adapter * @reg_addr: the register address * @val: the value to write * * Write a 32-bit value into the given HW register. */ static inline void t4_write_reg(struct adapter *adapter, u32 reg_addr, u32 val) { … } #ifndef readq static inline u64 readq(const volatile void __iomem *addr) { return readl(addr) + ((u64)readl(addr + 4) << 32); } static inline void writeq(u64 val, volatile void __iomem *addr) { writel(val, addr); writel(val >> 32, addr + 4); } #endif /** * t4_read_reg64 - read a 64-bit HW register * @adapter: the adapter * @reg_addr: the register address * * Returns the 64-bit value of the given HW register. */ static inline u64 t4_read_reg64(struct adapter *adapter, u32 reg_addr) { … } /** * t4_write_reg64 - write a 64-bit HW register * @adapter: the adapter * @reg_addr: the register address * @val: the value to write * * Write a 64-bit value into the given HW register. */ static inline void t4_write_reg64(struct adapter *adapter, u32 reg_addr, u64 val) { … } /** * port_name - return the string name of a port * @adapter: the adapter * @pidx: the port index * * Return the string name of the selected port. */ static inline const char *port_name(struct adapter *adapter, int pidx) { … } /** * t4_os_set_hw_addr - store a port's MAC address in SW * @adapter: the adapter * @pidx: the port index * @hw_addr: the Ethernet address * * Store the Ethernet address of the given port in SW. Called by the common * code when it retrieves a port's Ethernet address from EEPROM. */ static inline void t4_os_set_hw_addr(struct adapter *adapter, int pidx, u8 hw_addr[]) { … } /** * netdev2pinfo - return the port_info structure associated with a net_device * @dev: the netdev * * Return the struct port_info associated with a net_device */ static inline struct port_info *netdev2pinfo(const struct net_device *dev) { … } /** * adap2pinfo - return the port_info of a port * @adap: the adapter * @pidx: the port index * * Return the port_info structure for the adapter. */ static inline struct port_info *adap2pinfo(struct adapter *adapter, int pidx) { … } /** * netdev2adap - return the adapter structure associated with a net_device * @dev: the netdev * * Return the struct adapter associated with a net_device */ static inline struct adapter *netdev2adap(const struct net_device *dev) { … } /* * OS "Callback" function declarations. These are functions that the OS code * is "contracted" to provide for the common code. */ void t4vf_os_link_changed(struct adapter *, int, int); void t4vf_os_portmod_changed(struct adapter *, int); /* * SGE function prototype declarations. */ int t4vf_sge_alloc_rxq(struct adapter *, struct sge_rspq *, bool, struct net_device *, int, struct sge_fl *, rspq_handler_t); int t4vf_sge_alloc_eth_txq(struct adapter *, struct sge_eth_txq *, struct net_device *, struct netdev_queue *, unsigned int); void t4vf_free_sge_resources(struct adapter *); netdev_tx_t t4vf_eth_xmit(struct sk_buff *, struct net_device *); int t4vf_ethrx_handler(struct sge_rspq *, const __be64 *, const struct pkt_gl *); irq_handler_t t4vf_intr_handler(struct adapter *); irqreturn_t t4vf_sge_intr_msix(int, void *); int t4vf_sge_init(struct adapter *); void t4vf_sge_start(struct adapter *); void t4vf_sge_stop(struct adapter *); #endif /* __CXGB4VF_ADAPTER_H__ */