/* SPDX-License-Identifier: (GPL-2.0 OR Linux-OpenIB) OR BSD-2-Clause */ /* Copyright(c) 2023 Advanced Micro Devices, Inc. */ #ifndef _PDS_CORE_IF_H_ #define _PDS_CORE_IF_H_ #define PCI_VENDOR_ID_PENSANDO … #define PCI_DEVICE_ID_PENSANDO_CORE_PF … #define PCI_DEVICE_ID_VIRTIO_NET_TRANS … #define PCI_DEVICE_ID_PENSANDO_IONIC_ETH_VF … #define PCI_DEVICE_ID_PENSANDO_VDPA_VF … #define PDS_CORE_BARS_MAX … #define PDS_CORE_PCI_BAR_DBELL … /* Bar0 */ #define PDS_CORE_DEV_INFO_SIGNATURE … #define PDS_CORE_BAR0_SIZE … #define PDS_CORE_BAR0_DEV_INFO_REGS_OFFSET … #define PDS_CORE_BAR0_DEV_CMD_REGS_OFFSET … #define PDS_CORE_BAR0_DEV_CMD_DATA_REGS_OFFSET … #define PDS_CORE_BAR0_INTR_STATUS_OFFSET … #define PDS_CORE_BAR0_INTR_CTRL_OFFSET … #define PDS_CORE_DEV_CMD_DONE … #define PDS_CORE_DEVCMD_TIMEOUT … #define PDS_CORE_CLIENT_ID … #define PDS_CORE_ASIC_TYPE_CAPRI … /* * enum pds_core_cmd_opcode - Device commands */ enum pds_core_cmd_opcode { … }; /* * enum pds_core_status_code - Device command return codes */ enum pds_core_status_code { … }; /** * struct pds_core_drv_identity - Driver identity information * @drv_type: Driver type (enum pds_core_driver_type) * @os_dist: OS distribution, numeric format * @os_dist_str: OS distribution, string format * @kernel_ver: Kernel version, numeric format * @kernel_ver_str: Kernel version, string format * @driver_ver_str: Driver version, string format */ struct pds_core_drv_identity { … }; #define PDS_DEV_TYPE_MAX … /** * struct pds_core_dev_identity - Device identity information * @version: Version of device identify * @type: Identify type (0 for now) * @state: Device state * @rsvd: Word boundary padding * @nlifs: Number of LIFs provisioned * @nintrs: Number of interrupts provisioned * @ndbpgs_per_lif: Number of doorbell pages per LIF * @intr_coal_mult: Interrupt coalescing multiplication factor * Scale user-supplied interrupt coalescing * value in usecs to device units using: * device units = usecs * mult / div * @intr_coal_div: Interrupt coalescing division factor * Scale user-supplied interrupt coalescing * value in usecs to device units using: * device units = usecs * mult / div * @vif_types: How many of each VIF device type is supported */ struct pds_core_dev_identity { … }; #define PDS_CORE_IDENTITY_VERSION_1 … /** * struct pds_core_dev_identify_cmd - Driver/device identify command * @opcode: Opcode PDS_CORE_CMD_IDENTIFY * @ver: Highest version of identify supported by driver * * Expects to find driver identification info (struct pds_core_drv_identity) * in cmd_regs->data. Driver should keep the devcmd interface locked * while preparing the driver info. */ struct pds_core_dev_identify_cmd { … }; /** * struct pds_core_dev_identify_comp - Device identify command completion * @status: Status of the command (enum pds_core_status_code) * @ver: Version of identify returned by device * * Device identification info (struct pds_core_dev_identity) can be found * in cmd_regs->data. Driver should keep the devcmd interface locked * while reading the results. */ struct pds_core_dev_identify_comp { … }; /** * struct pds_core_dev_reset_cmd - Device reset command * @opcode: Opcode PDS_CORE_CMD_RESET * * Resets and clears all LIFs, VDevs, and VIFs on the device. */ struct pds_core_dev_reset_cmd { … }; /** * struct pds_core_dev_reset_comp - Reset command completion * @status: Status of the command (enum pds_core_status_code) */ struct pds_core_dev_reset_comp { … }; /* * struct pds_core_dev_init_data - Pointers and info needed for the Core * initialization PDS_CORE_CMD_INIT command. The in and out structs are * overlays on the pds_core_dev_cmd_regs.data space for passing data down * to the firmware on init, and then returning initialization results. */ struct pds_core_dev_init_data_in { … }; struct pds_core_dev_init_data_out { … }; /** * struct pds_core_dev_init_cmd - Core device initialize * @opcode: opcode PDS_CORE_CMD_INIT * * Initializes the core device and sets up the AdminQ and NotifyQ. * Expects to find initialization data (struct pds_core_dev_init_data_in) * in cmd_regs->data. Driver should keep the devcmd interface locked * while preparing the driver info. */ struct pds_core_dev_init_cmd { … }; /** * struct pds_core_dev_init_comp - Core init completion * @status: Status of the command (enum pds_core_status_code) * * Initialization result data (struct pds_core_dev_init_data_in) * is found in cmd_regs->data. */ struct pds_core_dev_init_comp { … }; /** * struct pds_core_fw_download_cmd - Firmware download command * @opcode: opcode * @rsvd: Word boundary padding * @addr: DMA address of the firmware buffer * @offset: offset of the firmware buffer within the full image * @length: number of valid bytes in the firmware buffer */ struct pds_core_fw_download_cmd { … }; /** * struct pds_core_fw_download_comp - Firmware download completion * @status: Status of the command (enum pds_core_status_code) */ struct pds_core_fw_download_comp { … }; /** * enum pds_core_fw_control_oper - FW control operations * @PDS_CORE_FW_INSTALL_ASYNC: Install firmware asynchronously * @PDS_CORE_FW_INSTALL_STATUS: Firmware installation status * @PDS_CORE_FW_ACTIVATE_ASYNC: Activate firmware asynchronously * @PDS_CORE_FW_ACTIVATE_STATUS: Firmware activate status * @PDS_CORE_FW_UPDATE_CLEANUP: Cleanup any firmware update leftovers * @PDS_CORE_FW_GET_BOOT: Return current active firmware slot * @PDS_CORE_FW_SET_BOOT: Set active firmware slot for next boot * @PDS_CORE_FW_GET_LIST: Return list of installed firmware images */ enum pds_core_fw_control_oper { … }; enum pds_core_fw_slot { … }; /** * struct pds_core_fw_control_cmd - Firmware control command * @opcode: opcode * @rsvd: Word boundary padding * @oper: firmware control operation (enum pds_core_fw_control_oper) * @slot: slot to operate on (enum pds_core_fw_slot) */ struct pds_core_fw_control_cmd { … }; /** * struct pds_core_fw_control_comp - Firmware control copletion * @status: Status of the command (enum pds_core_status_code) * @rsvd: Word alignment space * @slot: Slot number (enum pds_core_fw_slot) * @rsvd1: Struct padding * @color: Color bit */ struct pds_core_fw_control_comp { … }; struct pds_core_fw_name_info { … }; struct pds_core_fw_list_info { … } __packed; enum pds_core_vf_attr { … }; /** * enum pds_core_vf_link_status - Virtual Function link status * @PDS_CORE_VF_LINK_STATUS_AUTO: Use link state of the uplink * @PDS_CORE_VF_LINK_STATUS_UP: Link always up * @PDS_CORE_VF_LINK_STATUS_DOWN: Link always down */ enum pds_core_vf_link_status { … }; /** * struct pds_core_vf_setattr_cmd - Set VF attributes on the NIC * @opcode: Opcode * @attr: Attribute type (enum pds_core_vf_attr) * @vf_index: VF index * @macaddr: mac address * @vlanid: vlan ID * @maxrate: max Tx rate in Mbps * @spoofchk: enable address spoof checking * @trust: enable VF trust * @linkstate: set link up or down * @stats: stats addr struct * @stats.pa: set DMA address for VF stats * @stats.len: length of VF stats space * @pad: force union to specific size */ struct pds_core_vf_setattr_cmd { … }; struct pds_core_vf_setattr_comp { … }; /** * struct pds_core_vf_getattr_cmd - Get VF attributes from the NIC * @opcode: Opcode * @attr: Attribute type (enum pds_core_vf_attr) * @vf_index: VF index */ struct pds_core_vf_getattr_cmd { … }; struct pds_core_vf_getattr_comp { … }; enum pds_core_vf_ctrl_opcode { … }; /** * struct pds_core_vf_ctrl_cmd - VF control command * @opcode: Opcode for the command * @ctrl_opcode: VF control operation type * @vf_index: VF Index. It is unused if op START_ALL is used. */ struct pds_core_vf_ctrl_cmd { … }; /** * struct pds_core_vf_ctrl_comp - VF_CTRL command completion. * @status: Status of the command (enum pds_core_status_code) */ struct pds_core_vf_ctrl_comp { … }; /* * union pds_core_dev_cmd - Overlay of core device command structures */ pds_core_dev_cmd; /* * union pds_core_dev_comp - Overlay of core device completion structures */ pds_core_dev_comp; /** * struct pds_core_dev_hwstamp_regs - Hardware current timestamp registers * @tick_low: Low 32 bits of hardware timestamp * @tick_high: High 32 bits of hardware timestamp */ struct pds_core_dev_hwstamp_regs { … }; /** * struct pds_core_dev_info_regs - Device info register format (read-only) * @signature: Signature value of 0x44455649 ('DEVI') * @version: Current version of info * @asic_type: Asic type * @asic_rev: Asic revision * @fw_status: Firmware status * bit 0 - 1 = fw running * bit 4-7 - 4 bit generation number, changes on fw restart * @fw_heartbeat: Firmware heartbeat counter * @serial_num: Serial number * @fw_version: Firmware version * @oprom_regs: oprom_regs to store oprom debug enable/disable and bmp * @rsvd_pad1024: Struct padding * @hwstamp: Hardware current timestamp registers * @rsvd_pad2048: Struct padding */ struct pds_core_dev_info_regs { … } __packed; /** * struct pds_core_dev_cmd_regs - Device command register format (read-write) * @doorbell: Device Cmd Doorbell, write-only * Write a 1 to signal device to process cmd * @done: Command completed indicator, poll for completion * bit 0 == 1 when command is complete * @cmd: Opcode-specific command bytes * @comp: Opcode-specific response bytes * @rsvd: Struct padding * @data: Opcode-specific side-data */ struct pds_core_dev_cmd_regs { … } __packed; /** * struct pds_core_dev_regs - Device register format for bar 0 page 0 * @info: Device info registers * @devcmd: Device command registers */ struct pds_core_dev_regs { … } __packed; #ifndef __CHECKER__ static_assert(…); static_assert(…); static_assert(…); static_assert(…); static_assert(…); static_assert(…); static_assert(…); #endif /* __CHECKER__ */ #endif /* _PDS_CORE_IF_H_ */