| 1 |
/* SPDX-License-Identifier: GPL-2.0 */ |
| 2 |
/* Copyright (c) 2015 - 2025 Beijing WangXun Technology Co., Ltd. */ |
| 3 |
#ifndef _WX_MBX_H_ |
| 4 |
#define _WX_MBX_H_ |
| 5 |
|
| 6 |
#define WX_VXMAILBOX_SIZE 15 |
| 7 |
|
| 8 |
/* PF Registers */ |
| 9 |
#define WX_PXMAILBOX(i) (0x600 + (4 * (i))) /* i=[0,63] */ |
| 10 |
#define WX_PXMAILBOX_STS BIT(0) /* Initiate message send to VF */ |
| 11 |
#define WX_PXMAILBOX_ACK BIT(1) /* Ack message recv'd from VF */ |
| 12 |
#define WX_PXMAILBOX_PFU BIT(3) /* PF owns the mailbox buffer */ |
| 13 |
|
| 14 |
/* VF Registers */ |
| 15 |
#define WX_VXMAILBOX 0x600 |
| 16 |
#define WX_VXMAILBOX_REQ BIT(0) /* Request for PF Ready bit */ |
| 17 |
#define WX_VXMAILBOX_ACK BIT(1) /* Ack PF message received */ |
| 18 |
#define WX_VXMAILBOX_VFU BIT(2) /* VF owns the mailbox buffer */ |
| 19 |
#define WX_VXMAILBOX_PFU BIT(3) /* PF owns the mailbox buffer */ |
| 20 |
#define WX_VXMAILBOX_PFSTS BIT(4) /* PF wrote a message in the MB */ |
| 21 |
#define WX_VXMAILBOX_PFACK BIT(5) /* PF ack the previous VF msg */ |
| 22 |
#define WX_VXMAILBOX_RSTI BIT(6) /* PF has reset indication */ |
| 23 |
#define WX_VXMAILBOX_RSTD BIT(7) /* PF has indicated reset done */ |
| 24 |
#define WX_VXMAILBOX_R2C_BITS (WX_VXMAILBOX_RSTD | \ |
| 25 |
WX_VXMAILBOX_PFSTS | WX_VXMAILBOX_PFACK) |
| 26 |
|
| 27 |
#define WX_VXMBMEM 0x00C00 /* 16*4B */ |
| 28 |
#define WX_PXMBMEM(i) (0x5000 + (64 * (i))) /* i=[0,63] */ |
| 29 |
|
| 30 |
#define WX_VFLRE(i) (0x4A0 + (4 * (i))) /* i=[0,1] */ |
| 31 |
#define WX_VFLREC(i) (0x4A8 + (4 * (i))) /* i=[0,1] */ |
| 32 |
|
| 33 |
/* SR-IOV specific macros */ |
| 34 |
#define WX_MBVFICR(i) (0x480 + (4 * (i))) /* i=[0,3] */ |
| 35 |
#define WX_MBVFICR_VFREQ_MASK GENMASK(15, 0) |
| 36 |
#define WX_MBVFICR_VFACK_MASK GENMASK(31, 16) |
| 37 |
|
| 38 |
#define WX_VT_MSGTYPE_ACK BIT(31) |
| 39 |
#define WX_VT_MSGTYPE_NACK BIT(30) |
| 40 |
#define WX_VT_MSGTYPE_CTS BIT(29) |
| 41 |
#define WX_VT_MSGINFO_SHIFT 16 |
| 42 |
#define WX_VT_MSGINFO_MASK GENMASK(23, 16) |
| 43 |
|
| 44 |
enum wx_pfvf_api_rev { |
| 45 |
wx_mbox_api_null, |
| 46 |
wx_mbox_api_13 = 4, /* API version 1.3 */ |
| 47 |
wx_mbox_api_unknown, /* indicates that API version is not known */ |
| 48 |
}; |
| 49 |
|
| 50 |
/* mailbox API */ |
| 51 |
#define WX_VF_RESET 0x01 /* VF requests reset */ |
| 52 |
#define WX_VF_SET_MAC_ADDR 0x02 /* VF requests PF to set MAC addr */ |
| 53 |
#define WX_VF_SET_MULTICAST 0x03 /* VF requests PF to set MC addr */ |
| 54 |
#define WX_VF_SET_VLAN 0x04 /* VF requests PF to set VLAN */ |
| 55 |
#define WX_VF_SET_LPE 0x05 /* VF requests PF to set VMOLR.LPE */ |
| 56 |
#define WX_VF_SET_MACVLAN 0x06 /* VF requests PF unicast filter */ |
| 57 |
#define WX_VF_API_NEGOTIATE 0x08 /* negotiate API version */ |
| 58 |
#define WX_VF_GET_QUEUES 0x09 /* get queue configuration */ |
| 59 |
#define WX_VF_GET_RETA 0x0a /* VF request for RETA */ |
| 60 |
#define WX_VF_GET_RSS_KEY 0x0b /* get RSS key */ |
| 61 |
#define WX_VF_UPDATE_XCAST_MODE 0x0c |
| 62 |
#define WX_VF_GET_LINK_STATE 0x10 /* get vf link state */ |
| 63 |
#define WX_VF_GET_FW_VERSION 0x11 /* get fw version */ |
| 64 |
|
| 65 |
#define WX_VF_BACKUP 0x8001 /* VF requests backup */ |
| 66 |
|
| 67 |
#define WX_PF_CONTROL_MSG BIT(8) /* PF control message */ |
| 68 |
#define WX_PF_NOFITY_VF_LINK_STATUS 0x1 |
| 69 |
#define WX_PF_NOFITY_VF_NET_NOT_RUNNING BIT(31) |
| 70 |
|
| 71 |
#define WX_VF_TX_QUEUES 1 /* number of Tx queues supported */ |
| 72 |
#define WX_VF_RX_QUEUES 2 /* number of Rx queues supported */ |
| 73 |
#define WX_VF_TRANS_VLAN 3 /* Indication of port vlan */ |
| 74 |
#define WX_VF_DEF_QUEUE 4 /* Default queue offset */ |
| 75 |
|
| 76 |
#define WX_VF_PERMADDR_MSG_LEN 4 |
| 77 |
|
| 78 |
enum wxvf_xcast_modes { |
| 79 |
WXVF_XCAST_MODE_NONE = 0, |
| 80 |
WXVF_XCAST_MODE_MULTI, |
| 81 |
WXVF_XCAST_MODE_ALLMULTI, |
| 82 |
WXVF_XCAST_MODE_PROMISC, |
| 83 |
}; |
| 84 |
|
| 85 |
int wx_write_mbx_pf(struct wx *wx, u32 *msg, u16 size, u16 vf); |
| 86 |
int wx_read_mbx_pf(struct wx *wx, u32 *msg, u16 size, u16 vf); |
| 87 |
int wx_check_for_rst_pf(struct wx *wx, u16 mbx_id); |
| 88 |
int wx_check_for_msg_pf(struct wx *wx, u16 mbx_id); |
| 89 |
int wx_check_for_ack_pf(struct wx *wx, u16 mbx_id); |
| 90 |
|
| 91 |
int wx_read_posted_mbx(struct wx *wx, u32 *msg, u16 size); |
| 92 |
int wx_write_posted_mbx(struct wx *wx, u32 *msg, u16 size); |
| 93 |
int wx_check_for_rst_vf(struct wx *wx); |
| 94 |
int wx_check_for_msg_vf(struct wx *wx); |
| 95 |
int wx_read_mbx_vf(struct wx *wx, u32 *msg, u16 size); |
| 96 |
int wx_write_mbx_vf(struct wx *wx, u32 *msg, u16 size); |
| 97 |
int wx_init_mbx_params_vf(struct wx *wx); |
| 98 |
|
| 99 |
#endif /* _WX_MBX_H_ */ |