18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/* Copyright(c) 1999 - 2018 Intel Corporation. */
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ci#ifndef _IXGBE_MBX_H_
58c2ecf20Sopenharmony_ci#define _IXGBE_MBX_H_
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#include "ixgbe_type.h"
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#define IXGBE_VFMAILBOX_SIZE        16 /* 16 32 bit words - 64 bytes */
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#define IXGBE_VFMAILBOX             0x002FC
128c2ecf20Sopenharmony_ci#define IXGBE_VFMBMEM               0x00200
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci#define IXGBE_PFMAILBOX_STS   0x00000001 /* Initiate message send to VF */
158c2ecf20Sopenharmony_ci#define IXGBE_PFMAILBOX_ACK   0x00000002 /* Ack message recv'd from VF */
168c2ecf20Sopenharmony_ci#define IXGBE_PFMAILBOX_VFU   0x00000004 /* VF owns the mailbox buffer */
178c2ecf20Sopenharmony_ci#define IXGBE_PFMAILBOX_PFU   0x00000008 /* PF owns the mailbox buffer */
188c2ecf20Sopenharmony_ci#define IXGBE_PFMAILBOX_RVFU  0x00000010 /* Reset VFU - used when VF stuck */
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci#define IXGBE_MBVFICR_VFREQ_MASK 0x0000FFFF /* bits for VF messages */
218c2ecf20Sopenharmony_ci#define IXGBE_MBVFICR_VFREQ_VF1  0x00000001 /* bit for VF 1 message */
228c2ecf20Sopenharmony_ci#define IXGBE_MBVFICR_VFACK_MASK 0xFFFF0000 /* bits for VF acks */
238c2ecf20Sopenharmony_ci#define IXGBE_MBVFICR_VFACK_VF1  0x00010000 /* bit for VF 1 ack */
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci/* If it's a IXGBE_VF_* msg then it originates in the VF and is sent to the
278c2ecf20Sopenharmony_ci * PF.  The reverse is true if it is IXGBE_PF_*.
288c2ecf20Sopenharmony_ci * Message ACK's are the value or'd with 0xF0000000
298c2ecf20Sopenharmony_ci */
308c2ecf20Sopenharmony_ci#define IXGBE_VT_MSGTYPE_ACK      0x80000000  /* Messages below or'd with
318c2ecf20Sopenharmony_ci					       * this are the ACK */
328c2ecf20Sopenharmony_ci#define IXGBE_VT_MSGTYPE_NACK     0x40000000  /* Messages below or'd with
338c2ecf20Sopenharmony_ci					       * this are the NACK */
348c2ecf20Sopenharmony_ci#define IXGBE_VT_MSGTYPE_CTS      0x20000000  /* Indicates that VF is still
358c2ecf20Sopenharmony_ci						 clear to send requests */
368c2ecf20Sopenharmony_ci#define IXGBE_VT_MSGINFO_SHIFT    16
378c2ecf20Sopenharmony_ci/* bits 23:16 are used for exra info for certain messages */
388c2ecf20Sopenharmony_ci#define IXGBE_VT_MSGINFO_MASK     (0xFF << IXGBE_VT_MSGINFO_SHIFT)
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci/* definitions to support mailbox API version negotiation */
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci/*
438c2ecf20Sopenharmony_ci * Each element denotes a version of the API; existing numbers may not
448c2ecf20Sopenharmony_ci * change; any additions must go at the end
458c2ecf20Sopenharmony_ci */
468c2ecf20Sopenharmony_cienum ixgbe_pfvf_api_rev {
478c2ecf20Sopenharmony_ci	ixgbe_mbox_api_10,	/* API version 1.0, linux/freebsd VF driver */
488c2ecf20Sopenharmony_ci	ixgbe_mbox_api_20,	/* API version 2.0, solaris Phase1 VF driver */
498c2ecf20Sopenharmony_ci	ixgbe_mbox_api_11,	/* API version 1.1, linux/freebsd VF driver */
508c2ecf20Sopenharmony_ci	ixgbe_mbox_api_12,	/* API version 1.2, linux/freebsd VF driver */
518c2ecf20Sopenharmony_ci	ixgbe_mbox_api_13,	/* API version 1.3, linux/freebsd VF driver */
528c2ecf20Sopenharmony_ci	ixgbe_mbox_api_14,	/* API version 1.4, linux/freebsd VF driver */
538c2ecf20Sopenharmony_ci	/* This value should always be last */
548c2ecf20Sopenharmony_ci	ixgbe_mbox_api_unknown,	/* indicates that API version is not known */
558c2ecf20Sopenharmony_ci};
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci/* mailbox API, legacy requests */
588c2ecf20Sopenharmony_ci#define IXGBE_VF_RESET            0x01 /* VF requests reset */
598c2ecf20Sopenharmony_ci#define IXGBE_VF_SET_MAC_ADDR     0x02 /* VF requests PF to set MAC addr */
608c2ecf20Sopenharmony_ci#define IXGBE_VF_SET_MULTICAST    0x03 /* VF requests PF to set MC addr */
618c2ecf20Sopenharmony_ci#define IXGBE_VF_SET_VLAN         0x04 /* VF requests PF to set VLAN */
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci/* mailbox API, version 1.0 VF requests */
648c2ecf20Sopenharmony_ci#define IXGBE_VF_SET_LPE	0x05 /* VF requests PF to set VMOLR.LPE */
658c2ecf20Sopenharmony_ci#define IXGBE_VF_SET_MACVLAN	0x06 /* VF requests PF for unicast filter */
668c2ecf20Sopenharmony_ci#define IXGBE_VF_API_NEGOTIATE	0x08 /* negotiate API version */
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_ci/* mailbox API, version 1.1 VF requests */
698c2ecf20Sopenharmony_ci#define IXGBE_VF_GET_QUEUES	0x09 /* get queue configuration */
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ci/* GET_QUEUES return data indices within the mailbox */
728c2ecf20Sopenharmony_ci#define IXGBE_VF_TX_QUEUES	1	/* number of Tx queues supported */
738c2ecf20Sopenharmony_ci#define IXGBE_VF_RX_QUEUES	2	/* number of Rx queues supported */
748c2ecf20Sopenharmony_ci#define IXGBE_VF_TRANS_VLAN	3	/* Indication of port vlan */
758c2ecf20Sopenharmony_ci#define IXGBE_VF_DEF_QUEUE	4	/* Default queue offset */
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci/* mailbox API, version 1.2 VF requests */
788c2ecf20Sopenharmony_ci#define IXGBE_VF_GET_RETA	0x0a	/* VF request for RETA */
798c2ecf20Sopenharmony_ci#define IXGBE_VF_GET_RSS_KEY	0x0b	/* get RSS key */
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_ci#define IXGBE_VF_UPDATE_XCAST_MODE	0x0c
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_ci/* mailbox API, version 1.4 VF requests */
848c2ecf20Sopenharmony_ci#define IXGBE_VF_IPSEC_ADD	0x0d
858c2ecf20Sopenharmony_ci#define IXGBE_VF_IPSEC_DEL	0x0e
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_ci#define IXGBE_VF_GET_LINK_STATE 0x10 /* get vf link state */
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ci/* length of permanent address message returned from PF */
908c2ecf20Sopenharmony_ci#define IXGBE_VF_PERMADDR_MSG_LEN 4
918c2ecf20Sopenharmony_ci/* word in permanent address message with the current multicast type */
928c2ecf20Sopenharmony_ci#define IXGBE_VF_MC_TYPE_WORD     3
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_ci#define IXGBE_PF_CONTROL_MSG      0x0100 /* PF control message */
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_ci#define IXGBE_VF_MBX_INIT_TIMEOUT 2000 /* number of retries on mailbox */
978c2ecf20Sopenharmony_ci#define IXGBE_VF_MBX_INIT_DELAY   500  /* microseconds between retries */
988c2ecf20Sopenharmony_ci
998c2ecf20Sopenharmony_cis32 ixgbe_read_mbx(struct ixgbe_hw *, u32 *, u16, u16);
1008c2ecf20Sopenharmony_cis32 ixgbe_write_mbx(struct ixgbe_hw *, u32 *, u16, u16);
1018c2ecf20Sopenharmony_cis32 ixgbe_check_for_msg(struct ixgbe_hw *, u16);
1028c2ecf20Sopenharmony_cis32 ixgbe_check_for_ack(struct ixgbe_hw *, u16);
1038c2ecf20Sopenharmony_cis32 ixgbe_check_for_rst(struct ixgbe_hw *, u16);
1048c2ecf20Sopenharmony_ci#ifdef CONFIG_PCI_IOV
1058c2ecf20Sopenharmony_civoid ixgbe_init_mbx_params_pf(struct ixgbe_hw *);
1068c2ecf20Sopenharmony_ci#endif /* CONFIG_PCI_IOV */
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_ciextern const struct ixgbe_mbx_operations mbx_ops_generic;
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_ci#endif /* _IXGBE_MBX_H_ */
111