196de2506SJakub Kicinski /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */ 24ef6cbe8SPablo Cascón /* Copyright (C) 2017-2019 Netronome Systems, Inc. */ 325528d90SPablo Cascón 425528d90SPablo Cascón #ifndef _NFP_NET_SRIOV_H_ 525528d90SPablo Cascón #define _NFP_NET_SRIOV_H_ 625528d90SPablo Cascón 749db8a70SSimon Horman /* SRIOV VF configuration. 825528d90SPablo Cascón * The configuration memory begins with a mailbox region for communication with 925528d90SPablo Cascón * the firmware followed by individual VF entries. 1025528d90SPablo Cascón */ 1125528d90SPablo Cascón #define NFP_NET_VF_CFG_SZ 16 1225528d90SPablo Cascón #define NFP_NET_VF_CFG_MB_SZ 16 1325528d90SPablo Cascón 1425528d90SPablo Cascón /* VF config mailbox */ 1525528d90SPablo Cascón #define NFP_NET_VF_CFG_MB 0x0 1625528d90SPablo Cascón #define NFP_NET_VF_CFG_MB_CAP 0x0 1725528d90SPablo Cascón #define NFP_NET_VF_CFG_MB_CAP_MAC (0x1 << 0) 1825528d90SPablo Cascón #define NFP_NET_VF_CFG_MB_CAP_VLAN (0x1 << 1) 1925528d90SPablo Cascón #define NFP_NET_VF_CFG_MB_CAP_SPOOF (0x1 << 2) 2025528d90SPablo Cascón #define NFP_NET_VF_CFG_MB_CAP_LINK_STATE (0x1 << 3) 214ef6cbe8SPablo Cascón #define NFP_NET_VF_CFG_MB_CAP_TRUST (0x1 << 4) 2259359597SBaowen Zheng #define NFP_NET_VF_CFG_MB_CAP_VLAN_PROTO (0x1 << 5) 23*e0d0e1fdSBin Chen #define NFP_NET_VF_CFG_MB_CAP_RATE (0x1 << 6) 2425528d90SPablo Cascón #define NFP_NET_VF_CFG_MB_RET 0x2 2525528d90SPablo Cascón #define NFP_NET_VF_CFG_MB_UPD 0x4 2625528d90SPablo Cascón #define NFP_NET_VF_CFG_MB_UPD_MAC (0x1 << 0) 2725528d90SPablo Cascón #define NFP_NET_VF_CFG_MB_UPD_VLAN (0x1 << 1) 2825528d90SPablo Cascón #define NFP_NET_VF_CFG_MB_UPD_SPOOF (0x1 << 2) 2925528d90SPablo Cascón #define NFP_NET_VF_CFG_MB_UPD_LINK_STATE (0x1 << 3) 304ef6cbe8SPablo Cascón #define NFP_NET_VF_CFG_MB_UPD_TRUST (0x1 << 4) 3159359597SBaowen Zheng #define NFP_NET_VF_CFG_MB_UPD_VLAN_PROTO (0x1 << 5) 32*e0d0e1fdSBin Chen #define NFP_NET_VF_CFG_MB_UPD_RATE (0x1 << 6) 3325528d90SPablo Cascón #define NFP_NET_VF_CFG_MB_VF_NUM 0x7 3425528d90SPablo Cascón 3525528d90SPablo Cascón /* VF config entry 3625528d90SPablo Cascón * MAC_LO is set that the MAC address can be read in a single 6 byte read 3725528d90SPablo Cascón * by the NFP 3825528d90SPablo Cascón */ 3925528d90SPablo Cascón #define NFP_NET_VF_CFG_MAC 0x0 4025528d90SPablo Cascón #define NFP_NET_VF_CFG_MAC_HI 0x0 4125528d90SPablo Cascón #define NFP_NET_VF_CFG_MAC_LO 0x6 4225528d90SPablo Cascón #define NFP_NET_VF_CFG_CTRL 0x4 434ef6cbe8SPablo Cascón #define NFP_NET_VF_CFG_CTRL_TRUST 0x8 4425528d90SPablo Cascón #define NFP_NET_VF_CFG_CTRL_SPOOF 0x4 4525528d90SPablo Cascón #define NFP_NET_VF_CFG_CTRL_LINK_STATE 0x3 4625528d90SPablo Cascón #define NFP_NET_VF_CFG_LS_MODE_AUTO 0 4725528d90SPablo Cascón #define NFP_NET_VF_CFG_LS_MODE_ENABLE 1 4825528d90SPablo Cascón #define NFP_NET_VF_CFG_LS_MODE_DISABLE 2 4925528d90SPablo Cascón #define NFP_NET_VF_CFG_VLAN 0x8 5059359597SBaowen Zheng #define NFP_NET_VF_CFG_VLAN_PROT 0xffff0000 5125528d90SPablo Cascón #define NFP_NET_VF_CFG_VLAN_QOS 0xe000 5225528d90SPablo Cascón #define NFP_NET_VF_CFG_VLAN_VID 0x0fff 53*e0d0e1fdSBin Chen #define NFP_NET_VF_CFG_RATE 0xc 54*e0d0e1fdSBin Chen #define NFP_NET_VF_CFG_MIN_RATE 0x0000ffff 55*e0d0e1fdSBin Chen #define NFP_NET_VF_CFG_MAX_RATE 0xffff0000 56*e0d0e1fdSBin Chen 57*e0d0e1fdSBin Chen #define NFP_NET_VF_RATE_MAX 0xffff 5825528d90SPablo Cascón 5925528d90SPablo Cascón int nfp_app_set_vf_mac(struct net_device *netdev, int vf, u8 *mac); 6025528d90SPablo Cascón int nfp_app_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan, u8 qos, 6125528d90SPablo Cascón __be16 vlan_proto); 62*e0d0e1fdSBin Chen int nfp_app_set_vf_rate(struct net_device *netdev, int vf, int min_tx_rate, 63*e0d0e1fdSBin Chen int max_tx_rate); 6425528d90SPablo Cascón int nfp_app_set_vf_spoofchk(struct net_device *netdev, int vf, bool setting); 654ef6cbe8SPablo Cascón int nfp_app_set_vf_trust(struct net_device *netdev, int vf, bool setting); 6625528d90SPablo Cascón int nfp_app_set_vf_link_state(struct net_device *netdev, int vf, 6725528d90SPablo Cascón int link_state); 6825528d90SPablo Cascón int nfp_app_get_vf_config(struct net_device *netdev, int vf, 6925528d90SPablo Cascón struct ifla_vf_info *ivi); 7025528d90SPablo Cascón 7125528d90SPablo Cascón #endif /* _NFP_NET_SRIOV_H_ */ 72