162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci/* Copyright(c) 1999 - 2018 Intel Corporation. */
362306a36Sopenharmony_ci
462306a36Sopenharmony_ci#ifndef _IXGBE_MBX_H_
562306a36Sopenharmony_ci#define _IXGBE_MBX_H_
662306a36Sopenharmony_ci
762306a36Sopenharmony_ci#include "ixgbe_type.h"
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci#define IXGBE_VFMAILBOX_SIZE        16 /* 16 32 bit words - 64 bytes */
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ci#define IXGBE_VFMAILBOX             0x002FC
1262306a36Sopenharmony_ci#define IXGBE_VFMBMEM               0x00200
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ci#define IXGBE_PFMAILBOX_STS   0x00000001 /* Initiate message send to VF */
1562306a36Sopenharmony_ci#define IXGBE_PFMAILBOX_ACK   0x00000002 /* Ack message recv'd from VF */
1662306a36Sopenharmony_ci#define IXGBE_PFMAILBOX_VFU   0x00000004 /* VF owns the mailbox buffer */
1762306a36Sopenharmony_ci#define IXGBE_PFMAILBOX_PFU   0x00000008 /* PF owns the mailbox buffer */
1862306a36Sopenharmony_ci#define IXGBE_PFMAILBOX_RVFU  0x00000010 /* Reset VFU - used when VF stuck */
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ci#define IXGBE_MBVFICR_VFREQ_MASK 0x0000FFFF /* bits for VF messages */
2162306a36Sopenharmony_ci#define IXGBE_MBVFICR_VFREQ_VF1  0x00000001 /* bit for VF 1 message */
2262306a36Sopenharmony_ci#define IXGBE_MBVFICR_VFACK_MASK 0xFFFF0000 /* bits for VF acks */
2362306a36Sopenharmony_ci#define IXGBE_MBVFICR_VFACK_VF1  0x00010000 /* bit for VF 1 ack */
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_ci/* If it's a IXGBE_VF_* msg then it originates in the VF and is sent to the
2762306a36Sopenharmony_ci * PF.  The reverse is true if it is IXGBE_PF_*.
2862306a36Sopenharmony_ci * Message ACK's are the value or'd with 0xF0000000
2962306a36Sopenharmony_ci */
3062306a36Sopenharmony_ci#define IXGBE_VT_MSGTYPE_ACK      0x80000000  /* Messages below or'd with
3162306a36Sopenharmony_ci					       * this are the ACK */
3262306a36Sopenharmony_ci#define IXGBE_VT_MSGTYPE_NACK     0x40000000  /* Messages below or'd with
3362306a36Sopenharmony_ci					       * this are the NACK */
3462306a36Sopenharmony_ci#define IXGBE_VT_MSGTYPE_CTS      0x20000000  /* Indicates that VF is still
3562306a36Sopenharmony_ci						 clear to send requests */
3662306a36Sopenharmony_ci#define IXGBE_VT_MSGINFO_SHIFT    16
3762306a36Sopenharmony_ci/* bits 23:16 are used for exra info for certain messages */
3862306a36Sopenharmony_ci#define IXGBE_VT_MSGINFO_MASK     (0xFF << IXGBE_VT_MSGINFO_SHIFT)
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_ci/* definitions to support mailbox API version negotiation */
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_ci/*
4362306a36Sopenharmony_ci * Each element denotes a version of the API; existing numbers may not
4462306a36Sopenharmony_ci * change; any additions must go at the end
4562306a36Sopenharmony_ci */
4662306a36Sopenharmony_cienum ixgbe_pfvf_api_rev {
4762306a36Sopenharmony_ci	ixgbe_mbox_api_10,	/* API version 1.0, linux/freebsd VF driver */
4862306a36Sopenharmony_ci	ixgbe_mbox_api_20,	/* API version 2.0, solaris Phase1 VF driver */
4962306a36Sopenharmony_ci	ixgbe_mbox_api_11,	/* API version 1.1, linux/freebsd VF driver */
5062306a36Sopenharmony_ci	ixgbe_mbox_api_12,	/* API version 1.2, linux/freebsd VF driver */
5162306a36Sopenharmony_ci	ixgbe_mbox_api_13,	/* API version 1.3, linux/freebsd VF driver */
5262306a36Sopenharmony_ci	ixgbe_mbox_api_14,	/* API version 1.4, linux/freebsd VF driver */
5362306a36Sopenharmony_ci	/* This value should always be last */
5462306a36Sopenharmony_ci	ixgbe_mbox_api_unknown,	/* indicates that API version is not known */
5562306a36Sopenharmony_ci};
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_ci/* mailbox API, legacy requests */
5862306a36Sopenharmony_ci#define IXGBE_VF_RESET            0x01 /* VF requests reset */
5962306a36Sopenharmony_ci#define IXGBE_VF_SET_MAC_ADDR     0x02 /* VF requests PF to set MAC addr */
6062306a36Sopenharmony_ci#define IXGBE_VF_SET_MULTICAST    0x03 /* VF requests PF to set MC addr */
6162306a36Sopenharmony_ci#define IXGBE_VF_SET_VLAN         0x04 /* VF requests PF to set VLAN */
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_ci/* mailbox API, version 1.0 VF requests */
6462306a36Sopenharmony_ci#define IXGBE_VF_SET_LPE	0x05 /* VF requests PF to set VMOLR.LPE */
6562306a36Sopenharmony_ci#define IXGBE_VF_SET_MACVLAN	0x06 /* VF requests PF for unicast filter */
6662306a36Sopenharmony_ci#define IXGBE_VF_API_NEGOTIATE	0x08 /* negotiate API version */
6762306a36Sopenharmony_ci
6862306a36Sopenharmony_ci/* mailbox API, version 1.1 VF requests */
6962306a36Sopenharmony_ci#define IXGBE_VF_GET_QUEUES	0x09 /* get queue configuration */
7062306a36Sopenharmony_ci
7162306a36Sopenharmony_ci/* GET_QUEUES return data indices within the mailbox */
7262306a36Sopenharmony_ci#define IXGBE_VF_TX_QUEUES	1	/* number of Tx queues supported */
7362306a36Sopenharmony_ci#define IXGBE_VF_RX_QUEUES	2	/* number of Rx queues supported */
7462306a36Sopenharmony_ci#define IXGBE_VF_TRANS_VLAN	3	/* Indication of port vlan */
7562306a36Sopenharmony_ci#define IXGBE_VF_DEF_QUEUE	4	/* Default queue offset */
7662306a36Sopenharmony_ci
7762306a36Sopenharmony_ci/* mailbox API, version 1.2 VF requests */
7862306a36Sopenharmony_ci#define IXGBE_VF_GET_RETA	0x0a	/* VF request for RETA */
7962306a36Sopenharmony_ci#define IXGBE_VF_GET_RSS_KEY	0x0b	/* get RSS key */
8062306a36Sopenharmony_ci
8162306a36Sopenharmony_ci#define IXGBE_VF_UPDATE_XCAST_MODE	0x0c
8262306a36Sopenharmony_ci
8362306a36Sopenharmony_ci/* mailbox API, version 1.4 VF requests */
8462306a36Sopenharmony_ci#define IXGBE_VF_IPSEC_ADD	0x0d
8562306a36Sopenharmony_ci#define IXGBE_VF_IPSEC_DEL	0x0e
8662306a36Sopenharmony_ci
8762306a36Sopenharmony_ci#define IXGBE_VF_GET_LINK_STATE 0x10 /* get vf link state */
8862306a36Sopenharmony_ci
8962306a36Sopenharmony_ci/* length of permanent address message returned from PF */
9062306a36Sopenharmony_ci#define IXGBE_VF_PERMADDR_MSG_LEN 4
9162306a36Sopenharmony_ci/* word in permanent address message with the current multicast type */
9262306a36Sopenharmony_ci#define IXGBE_VF_MC_TYPE_WORD     3
9362306a36Sopenharmony_ci
9462306a36Sopenharmony_ci#define IXGBE_PF_CONTROL_MSG      0x0100 /* PF control message */
9562306a36Sopenharmony_ci
9662306a36Sopenharmony_ci#define IXGBE_VF_MBX_INIT_TIMEOUT 2000 /* number of retries on mailbox */
9762306a36Sopenharmony_ci#define IXGBE_VF_MBX_INIT_DELAY   500  /* microseconds between retries */
9862306a36Sopenharmony_ci
9962306a36Sopenharmony_cis32 ixgbe_read_mbx(struct ixgbe_hw *, u32 *, u16, u16);
10062306a36Sopenharmony_cis32 ixgbe_write_mbx(struct ixgbe_hw *, u32 *, u16, u16);
10162306a36Sopenharmony_cis32 ixgbe_check_for_msg(struct ixgbe_hw *, u16);
10262306a36Sopenharmony_cis32 ixgbe_check_for_ack(struct ixgbe_hw *, u16);
10362306a36Sopenharmony_cis32 ixgbe_check_for_rst(struct ixgbe_hw *, u16);
10462306a36Sopenharmony_ci#ifdef CONFIG_PCI_IOV
10562306a36Sopenharmony_civoid ixgbe_init_mbx_params_pf(struct ixgbe_hw *);
10662306a36Sopenharmony_ci#endif /* CONFIG_PCI_IOV */
10762306a36Sopenharmony_ci
10862306a36Sopenharmony_ciextern const struct ixgbe_mbx_operations mbx_ops_generic;
10962306a36Sopenharmony_ci
11062306a36Sopenharmony_ci#endif /* _IXGBE_MBX_H_ */
111