141 lines
4.8 KiB
C
141 lines
4.8 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/* Copyright(c) 2022 - 2024 Mucse Corporation. */
|
|
|
|
#ifndef _RNPVF_MBX_H_
|
|
#define _RNPVF_MBX_H_
|
|
|
|
#include "vf.h"
|
|
|
|
#define RNP_VFMAILBOX_SIZE 14 /* 16 32 bit words - 64 bytes */
|
|
#define RNP_ERR_MBX -100
|
|
|
|
struct mbx_shm {
|
|
u32 stat;
|
|
#define MBX_ST_PF_ACK (0x1 << 0)
|
|
#define MBX_ST_PF_STS (0x1 << 1)
|
|
#define MBX_ST_PF_RST (0x1 << 2)
|
|
|
|
#define MBX_ST_VF_ACK (0x1 << 3)
|
|
#define MBX_ST_VF_REQ (0x1 << 4)
|
|
#define MBX_ST_VF_RST (0x1 << 5)
|
|
|
|
#define MBX_ST_CPU_ACK (0x1 << 6)
|
|
#define MBX_ST_CPU_REQ (0x1 << 7)
|
|
|
|
u32 data[RNP_VFMAILBOX_SIZE];
|
|
} __aligned(4);
|
|
|
|
/* If it's a RNP_VF_* msg then it originates in the VF and is sent to the
|
|
* PF. The reverse is true if it is RNP_PF_*.
|
|
* Message ACK's are the value or'd with 0xF0000000
|
|
*/
|
|
#define RNP_VT_MSGTYPE_ACK 0x80000000
|
|
/* Messages below or'd with
|
|
* this are the ACK
|
|
*/
|
|
#define RNP_VT_MSGTYPE_NACK 0x40000000
|
|
/* Messages below or'd with
|
|
* this are the NACK
|
|
*/
|
|
#define RNP_VT_MSGTYPE_CTS 0x20000000
|
|
/* Indicates that VF is still
|
|
* clear to send requests
|
|
*/
|
|
#define RNP_VT_MSGINFO_SHIFT 14
|
|
/* bits 23:16 are used for exra info for certain messages */
|
|
#define RNP_VT_MSGINFO_MASK (0xFF << RNP_VT_MSGINFO_SHIFT)
|
|
|
|
/* mailbox API, legacy requests */
|
|
#define RNP_VF_RESET 0x01 /* VF requests reset */
|
|
#define RNP_VF_SET_MAC_ADDR 0x02 /* VF requests PF to set MAC addr */
|
|
#define RNP_VF_SET_MULTICAST 0x03 /* VF requests PF to set MC addr */
|
|
#define RNP_VF_SET_VLAN 0x04 /* VF requests PF to set VLAN */
|
|
|
|
/* mailbox API, version 1.0 VF requests */
|
|
#define RNP_VF_SET_LPE 0x05 /* VF requests PF to set VMOLR.LPE */
|
|
#define RNP_VF_SET_MACVLAN 0x06 /* VF requests PF for unicast filter */
|
|
#define RNP_VF_GET_MACVLAN 0x07 /* VF requests mac */
|
|
#define RNP_VF_API_NEGOTIATE 0x08 /* negotiate API version */
|
|
|
|
/* mailbox API, version 1.1 VF requests */
|
|
#define RNP_VF_GET_QUEUE 0x09 /* get queue configuration */
|
|
#define RNP_VF_SET_VLAN_STRIP 0x0a /* VF requests PF to set VLAN STRIP */
|
|
#define RNP_VF_REG_RD 0x0b /* vf read reg */
|
|
#define RNP_VF_GET_MTU 0x0c /* vf read reg */
|
|
#define RNP_VF_SET_MTU 0x0d /* vf read reg */
|
|
#define RNP_VF_GET_FW 0x0e /* vf read reg */
|
|
#define RNP_VF_RESET_PF 0x13 /* vf read reg */
|
|
|
|
#define RNP_PF_VFNUM_MASK (0x3f << 21)
|
|
#define RNP_PF_SET_FCS 0x10 /* PF set fcs status */
|
|
#define RNP_PF_SET_PAUSE 0x11 /* PF set pause status */
|
|
#define RNP_PF_SET_FT_PADDING 0x12 /* PF set ft padding status */
|
|
#define RNP_PF_SET_VLAN_FILTER 0x13
|
|
#define RNP_PF_SET_VLAN 0x14
|
|
#define RNP_PF_SET_LINK 0x15
|
|
#define RNP_PF_SET_MTU 0x16
|
|
#define RNP_PF_SET_RESET 0x17
|
|
#define RNP_PF_LINK_UP (0x1 << 31)
|
|
|
|
#define RNP_PF_REMOVE 0x0f
|
|
#define RNP_PF_GET_LINK 0x10
|
|
/* GET_QUEUES return data indices within the mailbox */
|
|
#define RNP_VF_TX_QUEUES 1 /* number of Tx queues supported */
|
|
#define RNP_VF_RX_QUEUES 2 /* number of Rx queues supported */
|
|
#define RNP_VF_TRANS_VLAN 3 /* Indication of port vlan */
|
|
#define RNP_VF_DEF_QUEUE 4 /* Default queue offset */
|
|
|
|
/* length of permanent address message returned from PF */
|
|
#define RNP_VF_PERMADDR_MSG_LEN 11
|
|
/* word in permanent address message with the current multicast type */
|
|
#define RNP_VF_MC_TYPE_WORD 3
|
|
#define RNP_VF_DMA_VERSION_WORD 4
|
|
#define RNP_VF_VLAN_WORD 5
|
|
#define RNP_VF_PHY_TYPE_WORD 6
|
|
#define RNP_VF_FW_VERSION_WORD 7
|
|
#define RNP_VF_LINK_STATUS_WORD 8
|
|
#define RNP_VF_AXI_MHZ 9
|
|
#define RNP_VF_FEATURE 10
|
|
|
|
#define RNP_PF_CONTROL_PRING_MSG 0x0100 /* PF control message */
|
|
|
|
#define RNP_VF_MBX_INIT_TIMEOUT 2000 /* number of retries on mailbox */
|
|
#define RNP_VF_MBX_INIT_DELAY 500 /* microseconds between retries */
|
|
|
|
/* forward declaration of the HW struct */
|
|
struct rnpvf_hw;
|
|
|
|
enum MBX_ID {
|
|
MBX_VF0 = 0,
|
|
MBX_VF1,
|
|
//...
|
|
MBX_VF63,
|
|
MBX_CM3CPU,
|
|
MBX_VFCNT
|
|
};
|
|
|
|
#define PF2VF_MBOX_VEC(mbx, vf) (mbx->pf2vf_mbox_vec_base + 4 * (vf))
|
|
#define CPU2VF_MBOX_VEC(mbx, vf) (mbx->cpu2vf_mbox_vec_base + 4 * (vf))
|
|
#define PF_VF_SHM(mbx, vf) \
|
|
((mbx->pf_vf_shm_base) + \
|
|
(64 * (vf)))
|
|
#define PF2VF_COUNTER(mbx, vf) (PF_VF_SHM(mbx, vf) + 0)
|
|
#define VF2PF_COUNTER(mbx, vf) (PF_VF_SHM(mbx, vf) + 4)
|
|
#define PF_VF_SHM_DATA(mbx, vf) (PF_VF_SHM(mbx, vf) + 8)
|
|
#define VF2PF_MBOX_CTRL(mbx, vf) ((mbx->vf2pf_mbox_ctrl_base) + (4 * (vf)))
|
|
|
|
/* === CPU <--> VF === */
|
|
#define CPU_VF_SHM(mbx, vf) (mbx->cpu_vf_shm_base + (64 * (vf)))
|
|
#define CPU2VF_COUNTER(mbx, vf) (CPU_VF_SHM(mbx, vf) + 0)
|
|
#define VF2CPU_COUNTER(mbx, vf) (CPU_VF_SHM(mbx, vf) + 4)
|
|
#define CPU_VF_SHM_DATA(mbx, vf) (CPU_VF_SHM(mbx, vf) + 8)
|
|
#define VF2CPU_MBOX_CTRL(mbx, vf) (mbx->vf2cpu_mbox_ctrl_base + 64 * (vf))
|
|
#define CPU_VF_MBOX_MASK_LO(mbx, vf) (mbx->cpu_vf_mbox_mask_lo_base + 64 * (vf))
|
|
#define CPU_VF_MBOX_MASK_HI(mbx, vf) (mbx->cpu_vf_mbox_mask_hi_base + 64 * (vf))
|
|
#define MBOX_CTRL_REQ (0x1 << 0) /* WO */
|
|
#define MBOX_CTRL_VF_HOLD_SHM (0x1 << 2) /* VF:WR, PF:RO */
|
|
#define MBOX_IRQ_EN 0
|
|
#define MBOX_IRQ_DISABLE 1
|
|
|
|
#endif /* _RNPVF_MBX_H_ */
|