/********************************************************************** * Author: Cavium, Inc. * * Contact: support@cavium.com * Please include "LiquidIO" in the subject. * * Copyright (c) 2003-2016 Cavium, Inc. * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, Version 2, as * published by the Free Software Foundation. * * This file is distributed in the hope that it will be useful, but * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or * NONINFRINGEMENT. See the GNU General Public License for more details.
***********************************************************************/ /*! \file octeon_device.h * \brief Host Driver: This file defines the octeon device structure.
*/
/** PCI VendorId Device Id */ #define OCTEON_CN68XX_PCIID 0x91177d #define OCTEON_CN66XX_PCIID 0x92177d #define OCTEON_CN23XX_PCIID_PF 0x9702177d /** Driver identifies chips by these Ids, created by clubbing together * DeviceId+RevisionId; Where Revision Id is not used to distinguish * between chips, a value of 0 is used for revision id.
*/ #define OCTEON_CN68XX 0x0091 #define OCTEON_CN66XX 0x0092 #define OCTEON_CN23XX_PF_VID 0x9702 #define OCTEON_CN23XX_VF_VID 0x9712
/**RevisionId for the chips */ #define OCTEON_CN23XX_REV_1_0 0x00 #define OCTEON_CN23XX_REV_1_1 0x01 #define OCTEON_CN23XX_REV_2_0 0x80
/**SubsystemId for the chips */ #define OCTEON_CN2350_10GB_SUBSYS_ID_1 0X3177d #define OCTEON_CN2350_10GB_SUBSYS_ID_2 0X4177d #define OCTEON_CN2360_10GB_SUBSYS_ID 0X5177d #define OCTEON_CN2350_25GB_SUBSYS_ID 0X7177d #define OCTEON_CN2360_25GB_SUBSYS_ID 0X6177d
/** The dispatch list entry. * The driver keeps a record of functions registered for each * response header opcode in this structure. Since the opcode is * hashed to index into the driver's list, more than one opcode * can hash to the same entry, in which case the list field points * to a linked list with the other entries.
*/ struct octeon_dispatch { /** List head for this entry */ struct list_head list;
/** The opcode for which the dispatch function & arg should be used */
u16 opcode;
/** The function to be called for a packet received by the driver */
octeon_dispatch_fn_t dispatch_fn;
/* The application specified argument to be passed to the above * function along with the received packet
*/ void *arg;
};
/** The dispatch list structure. */ struct octeon_dispatch_list { /** access to dispatch list must be atomic */
spinlock_t lock;
/** Count of dispatch functions currently registered */
u32 count;
/** The list of dispatch functions */ struct octeon_dispatch *dlist;
};
/*----------------------- THE OCTEON DEVICE ---------------------------*/
#define OCT_MEM_REGIONS 3 /** PCI address space mapping information. * Each of the 3 address spaces given by BAR0, BAR2 and BAR4 of * Octeon gets mapped to different physical address spaces in * the kernel.
*/ struct octeon_mmio { /** PCI address to which the BAR is mapped. */
u64 start;
/** Length of this PCI address space. */
u32 len;
/** Length that has been mapped to phys. address space. */
u32 mapped_len;
/** The physical address to which the PCI address space is mapped. */
u8 __iomem *hw_addr;
/** Flag indicating the mapping was successful. */
u32 done;
};
int (*enable_io_queues)(struct octeon_device *); void (*disable_io_queues)(struct octeon_device *);
};
/* Must be multiple of 8, changing breaks ABI */ #define CVMX_BOOTMEM_NAME_LEN 128
/* Structure for named memory blocks * Number of descriptors * available can be changed without affecting compatibility, * but name length changes require a bump in the bootmem * descriptor version * Note: This structure must be naturally 64 bit aligned, as a single * memory image will be used by both 32 and 64 bit programs.
*/ struct cvmx_bootmem_named_block_desc { /** Base address of named block */
u64 base_addr;
/** Size actually allocated for named block */
u64 size;
/** name of named block */ char name[CVMX_BOOTMEM_NAME_LEN];
};
struct oct_fw_info {
u32 max_nic_ports; /** max nic ports for the device */
u32 num_gmx_ports; /** num gmx ports */
u64 app_cap_flags; /** firmware cap flags */
/** The core application is running in this mode. * See octeon-drv-opcodes.h for values.
*/
u32 app_mode; char liquidio_firmware_version[32]; /* Fields extracted from legacy string 'liquidio_firmware_version' */ struct {
u8 maj;
u8 min;
u8 rev;
} ver;
};
struct octdev_props { /* Each interface in the Octeon device has a network * device pointer (used for OS specific calls).
*/ int rx_on; int fec; int fec_boot; int napi_enabled; int gmxport; struct net_device *netdev;
};
/** PKIND value assigned for the DPI interface */
u64 pkind : 8; #endif
};
struct octeon_sriov_info { /* Number of rings assigned to VF */
u32 rings_per_vf;
/** Max Number of VF devices that can be enabled. This variable can * specified during load time or it will be derived after allocating * PF queues. When max_vfs is derived then each VF will get one queue
**/
u32 max_vfs;
/** Number of VF devices enabled using sysfs. */
u32 num_vfs_alloced;
/* Actual rings left for PF device */
u32 num_pf_rings;
/* SRN of PF usable IO queues */
u32 pf_srn;
/* total pf rings */
u32 trs;
u32 sriov_enabled;
struct lio_trusted_vf trusted_vf;
/*lookup table that maps DPI ring number to VF pci_dev struct pointer*/ struct pci_dev *dpiring_to_vfpcidev_lut[MAX_POSSIBLE_VFS];
u64 vf_macaddr[MAX_POSSIBLE_VFS];
u16 vf_vlantci[MAX_POSSIBLE_VFS];
int vf_linkstate[MAX_POSSIBLE_VFS];
bool vf_spoofchk[MAX_POSSIBLE_VFS];
u64 vf_drv_loaded_mask;
};
struct octeon_ioq_vector { struct octeon_device *oct_dev; int iq_index; int droq_index; int vector; struct octeon_mbox *mbox; struct cpumask affinity_mask;
u32 ioq_num;
};
struct lio_vf_rep_list { int num_vfs; struct net_device *ndev[CN23XX_MAX_VFS_PER_PF];
};
/** The Octeon device. * Each Octeon device has this structure to represent all its * components.
*/ struct octeon_device { /** Lock for PCI window configuration accesses */
spinlock_t pci_win_lock;
/** Lock for memory accesses */
spinlock_t mem_access_lock;
/*------------------ Function Prototypes ----------------------*/
/** Initialize device list memory */ void octeon_init_device_list(int conf_type);
/** Free memory for Input and Output queue structures for a octeon device */ void octeon_free_device_mem(struct octeon_device *oct);
/* Look up a free entry in the octeon_device table and allocate resources * for the octeon_device structure for an octeon device. Called at init * time.
*/ struct octeon_device *octeon_allocate_device(u32 pci_id,
u32 priv_size);
/** Register a device's bus location at initialization time. * @param octeon_dev - pointer to the octeon device structure. * @param bus - PCIe bus # * @param dev - PCIe device # * @param func - PCIe function # * @param is_pf - TRUE for PF, FALSE for VF * @return reference count of device's adapter
*/ int octeon_register_device(struct octeon_device *oct, int bus, int dev, int func, int is_pf);
/** Deregister a device at de-initialization time. * @param octeon_dev - pointer to the octeon device structure. * @return reference count of device's adapter
*/ int octeon_deregister_device(struct octeon_device *oct);
/** Initialize the driver's dispatch list which is a mix of a hash table * and a linked list. This is done at driver load time. * @param octeon_dev - pointer to the octeon device structure. * @return 0 on success, else -ve error value
*/ int octeon_init_dispatch_list(struct octeon_device *octeon_dev);
/** Delete the driver's dispatch list and all registered entries. * This is done at driver unload time. * @param octeon_dev - pointer to the octeon device structure.
*/ void octeon_delete_dispatch_list(struct octeon_device *octeon_dev);
/** Initialize the core device fields with the info returned by the FW. * @param recv_info - Receive info structure * @param buf - Receive buffer
*/ int octeon_core_drv_init(struct octeon_recv_info *recv_info, void *buf);
/** Gets the dispatch function registered to receive packets with a * given opcode/subcode. * @param octeon_dev - the octeon device pointer. * @param opcode - the opcode for which the dispatch function * is to checked. * @param subcode - the subcode for which the dispatch function * is to checked. * * @return Success: octeon_dispatch_fn_t (dispatch function pointer) * @return Failure: NULL * * Looks up the dispatch list to get the dispatch function for a * given opcode.
*/
octeon_dispatch_fn_t
octeon_get_dispatch(struct octeon_device *octeon_dev, u16 opcode,
u16 subcode);
/** Get the octeon device pointer. * @param octeon_id - The id for which the octeon device pointer is required. * @return Success: Octeon device pointer. * @return Failure: NULL.
*/ struct octeon_device *lio_get_device(u32 octeon_id);
/** Read windowed register. * @param oct - pointer to the Octeon device. * @param addr - Address of the register to read. * * This routine is called to read from the indirectly accessed * Octeon registers that are visible through a PCI BAR0 mapped window * register. * @return - 64 bit value read from the register.
*/
/** Write windowed register. * @param oct - pointer to the Octeon device. * @param val - Value to write * @param addr - Address of the register to write * * This routine is called to write to the indirectly accessed * Octeon registers that are visible through a PCI BAR0 mapped window * register. * @return Nothing.
*/ void lio_pci_writeq(struct octeon_device *oct, u64 val, u64 addr);
/* Routines for reading and writing CSRs */ #define octeon_write_csr(oct_dev, reg_off, value) \
writel(value, (oct_dev)->mmio[0].hw_addr + (reg_off))
/** * Checks if memory access is okay * * @param oct which octeon to send to * @return Zero on success, negative on failure.
*/ int octeon_mem_access_ok(struct octeon_device *oct);
/** * Waits for DDR initialization. * * @param oct which octeon to send to * @param timeout_in_ms pointer to how long to wait until DDR is initialized * in ms. * If contents are 0, it waits until contents are non-zero * before starting to check. * @return Zero on success, negative on failure.
*/ int octeon_wait_for_ddr_init(struct octeon_device *oct,
u32 *timeout_in_ms);
/** * Wait for u-boot to boot and be waiting for a command. * * @param wait_time_hundredths * Maximum time to wait * * @return Zero on success, negative on failure.
*/ int octeon_wait_for_bootloader(struct octeon_device *oct,
u32 wait_time_hundredths);
/** * Initialize console access * * @param oct which octeon initialize * @return Zero on success, negative on failure.
*/ int octeon_init_consoles(struct octeon_device *oct);
/** * Adds access to a console to the device. * * @param oct: which octeon to add to * @param console_num: which console * @param dbg_enb: ptr to debug enablement string, one of: * * NULL for no debug output (i.e. disabled) * * empty string enables debug output (via default method) * * specific string to enable debug console output * * @return Zero on success, negative on failure.
*/ int octeon_add_console(struct octeon_device *oct, u32 console_num, char *dbg_enb);
/** Removes all attached consoles. */ void octeon_remove_consoles(struct octeon_device *oct);
/** * Send a string to u-boot on console 0 as a command. * * @param oct which octeon to send to * @param cmd_str String to send * @param wait_hundredths Time to wait for u-boot to accept the command. * * @return Zero on success, negative on failure.
*/ int octeon_console_send_cmd(struct octeon_device *oct, char *cmd_str,
u32 wait_hundredths);
/** Parses, validates, and downloads firmware, then boots associated cores. * @param oct which octeon to download firmware to * @param data - The complete firmware file image * @param size - The size of the data * * @return 0 if success. * -EINVAL if file is incompatible or badly formatted. * -ENODEV if no handler was found for the application type or an * invalid octeon id was passed.
*/ int octeon_download_firmware(struct octeon_device *oct, const u8 *data,
size_t size);
char *lio_get_state_string(atomic_t *state_ptr);
/** Sets up instruction queues for the device * @param oct which octeon to setup * * @return 0 if success. 1 if fails
*/ int octeon_setup_instr_queues(struct octeon_device *oct);
/** Sets up output queues for the device * @param oct which octeon to setup * * @return 0 if success. 1 if fails
*/ int octeon_setup_output_queues(struct octeon_device *oct);
int octeon_get_tx_qsize(struct octeon_device *oct, u32 q_no);
int octeon_get_rx_qsize(struct octeon_device *oct, u32 q_no);
/** Turns off the input and output queues for the device * @param oct which octeon to disable
*/ int octeon_set_io_queues_off(struct octeon_device *oct);
/** Turns on or off the given output queue for the device * @param oct which octeon to change * @param q_no which queue * @param enable 1 to enable, 0 to disable
*/ void octeon_set_droq_pkt_op(struct octeon_device *oct, u32 q_no, u32 enable);
/** Retrieve the config for the device * @param oct which octeon * @param card_type type of card * * @returns pointer to configuration
*/ void *oct_get_config_info(struct octeon_device *oct, u16 card_type);
/** Gets the octeon device configuration * @return - pointer to the octeon configuration struture
*/ struct octeon_config *octeon_get_conf(struct octeon_device *oct);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.