Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758953AbcLUJE2 (ORCPT ); Wed, 21 Dec 2016 04:04:28 -0500 Received: from mail-bn3nam01on0059.outbound.protection.outlook.com ([104.47.33.59]:8544 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1758800AbcLUJEJ (ORCPT ); Wed, 21 Dec 2016 04:04:09 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Satha.Rao@cavium.com; From: Satha Koteswara Rao To: CC: , , , , , , , , , Subject: [RFC PATCH 5/7] Multiple VF's grouped together under single physical port called PF group PF Group maintainance API's Date: Wed, 21 Dec 2016 14:16:49 +0530 Message-ID: <1482310011-1862-6-git-send-email-satha.rao@caviumnetworks.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1482310011-1862-1-git-send-email-satha.rao@caviumnetworks.com> References: <1482310011-1862-1-git-send-email-satha.rao@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [111.93.218.67] X-ClientProxiedBy: MAXPR01CA0030.INDPRD01.PROD.OUTLOOK.COM (10.164.147.37) To CY4PR07MB2838.namprd07.prod.outlook.com (10.169.252.16) X-MS-Office365-Filtering-Correlation-Id: f4a2a9f2-6885-41e8-c611-08d4297e22c0 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:CY4PR07MB2838; X-Microsoft-Exchange-Diagnostics: 1;CY4PR07MB2838;3:52GnTyqb3VxNyg57WWSae7ayCGMKkK8Rg04yVKYY1NIR9yJSk+8WFDnlagwVFGbVGD74G9u/kM0asdRHpu+pCV/+4IEh5olJhmnm1jw2nnYUCVEk4tZ8BWEgXWP8aKQ2T+5R3sTBMgTcM35sANkJ7XTIHu3xA1GDneDqxK+FnoQV984tCaFoQ5vAcjb6DfzOEX7cW2yrY8TVbJ5F7h4+LT4QrGyqPCm1Mw+/LL9Z2brAcmkeG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VNwCVfakfTLGxd3CqwBsq7lIj6ISip1nQd6T4HcTdM7tqJcvoyVxZ1u6A9ILE+bSuAp99lY9113XyQ7tpKAvGF0YqNa14hjq2Z3xhTRQXJOf8pyriEUC5B5Lg06NZzv;20:lr/oL3dnlsfRsKEJpFSsx9itKNYVtDUkVGQxoiIbZt/RH8s/1EPQR2qr+w2smZ3DRfxkNW10tknxBqX2zlcAUreBOiNHwtBbxKjYWJB2WImrLhXF/natPMT47V6OyavGrDw30GhaNHx4G64MHTB3bLy5XLcMljvl1cEqeae63LVRlobGK2twfm9mKMagNU/o3wfL91BiNmZGTnIf9YLR4FCVMSuZ2eoPcMhBY98YKhb2/E2fQmi7wx0Sy/vVhH2EAZpaoSxvHKRnvIhGlbVD95bCXILHZ+t2Y/nTY4ZNA+JeeZt7fnL0nnG4uNt4bamrFcidDAme2TgGyI/3MN92VRq0v5AvJiYMAOE7iLFeJRw14qigf5hWO0XI+EsD8UPnwFaSC7yhyj468a7Yzpl8DzP5tcK4uFTCg2hHeL1XN4F8HBX4Spc18wPERRAp6ESifAU6Qs5ZTT5BSc0xvFe3n/lY8HxrEo2rXvcpMiFC6f1eXfZov5BkNUXuKz3vaMpNpqqN/liycQfLRqHbh3ZrSidHc9lwuh2TqRJHpSOHTpHiY75dGIXZ1NqA5uc3cN7BVB5sfOVxPClr4g+THW/Xzb02dmEDeoHH5wZeDvA81JA= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(6041248)(20161123562025)(20161123564025)(20161123560025)(20161123555025)(6072148);SRVR:CY4PR07MB2838;BCL:0;PCL:0;RULEID:;SRVR:CY4PR07MB2838; X-Microsoft-Exchange-Diagnostics: 1;CY4PR07MB2838;4:ch+JbOHSyxMpVx6x8VXERBMWaXVFFhznqRFWd78Llj+GQrLZ39EXi9OoUbN6QjxfKvJx0xA3Bk+XdIY/V+14Zh3selyq9h0Dy5NQsFS9g4ABfWuh3aILeSLGMfu0coOw7tecNvP3HJlxgGxqlj5qQAbw0F6l1JEJ0T7lDzuPYUu034vLynnqHj32MJXkPMCzyoxkezNVIzo4+vbiz3Jlro7KlwHHwdgQ0bOfSF7oMzHcuiIX4Retk0P4hXXH7aUgCMw+jHr+6m7h3VgjDUhL/frObK9bw4SCl2pt2xxz5zahMmdRSzlncXfANepbUzL7xqDIelYRGJuUcpq+qSkRVvbUfn3qJSpZ3o2654M8GVVNtz/8yKWI/EtN4Q8VZRUjM9fH+Bt8PB7il9sw6KL1jlYNdSdFg8my0eJkRDYIVr4bRKhn7DdaUFHYTS/ES+yW/nfiwercLQ4g1rKZcA4ljhXV5D1oZnJGS8sAd+0Zly2DpwRjAyvzkguJLjHDejYY7JRYT1ckFVUlAokIV0O73Yid5BD+t4oV/5BHD4DVTRklDHka2MPOH9u4Sb50u1cz X-Forefront-PRVS: 01630974C0 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6069001)(6009001)(7916002)(39450400003)(189002)(199003)(2906002)(4326007)(101416001)(33646002)(5009440100003)(106356001)(2351001)(68736007)(105586002)(8676002)(50986999)(5003940100001)(53416004)(76506005)(76176999)(48376002)(81156014)(81166006)(42186005)(66066001)(5660300001)(92566002)(50466002)(6506006)(110136003)(7736002)(6916009)(47776003)(189998001)(36756003)(6116002)(6666003)(50226002)(3846002)(97736004)(42882006)(25786008)(2950100002)(305945005)(6512006)(69596002)(38730400001)(6486002)(4720700003)(7099028)(2004002)(217873001);DIR:OUT;SFP:1101;SCL:1;SRVR:CY4PR07MB2838;H:localhost.caveonetworks.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;CY4PR07MB2838;23:Q+LQdGF//0VKD2jZqiSy4OEXOYk3xTJ3x0++v5SU+?= =?us-ascii?Q?yvFLXWIQnkms/BLuLmYj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9GYFkhQ==;24:kBPgvce1vwV9Nt282tw3gn58TI4qTGIfXXhYIti5TxStu/I+GTynS5zfR0wH9hsN/F8t8YboDwYDD99JKeejqqEGDYXmcARl+T4lmZ5ZcUc= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;CY4PR07MB2838;7:Cfbw2LfCjCATcxFVfgpWNB7qGQkW8sI5tMHgwx3qt6FqHAfFk0aGLTLncSAkkLcPAxnNhA3rFobacYMDJrKjtfg2I/r6XrprdOXYa1smOydUjFWnYg3816h1UcN8/dsm9Y+0qy0Ls9WA7W6hAehAeEYFxhpf18DR6RZsONFP3YpyNt8jA/tssvoyHneVQChyxEzrdX1xD3IDWWXdHsj15iMhrfnKYRTzhvhWoG+WCI7XoTD6q+i0saBwv7DYk5lNz1vVZvXLZSj3rzcMcrHPSLQAFRCp8prjnzQDFbfk1G3b5PVo+4LkYpr0WPMG2vX9bAYflVyEDP1A2a06Fx4sVjb3sgWTca17qemZooIuGK7bGuCwTViMFNciZKAtgb3LqnppWRVAOQ+zcsFjRjFxK77s3HwgAC31z1oip+2vQ3TBM8wfHGxe1ta5N8tG2VzweUkiHMezL7+jSGOUNZoe2A== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Dec 2016 08:48:25.6920 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR07MB2838 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 16562 Lines: 679 --- drivers/net/ethernet/cavium/thunder/pf_globals.h | 78 +++++ drivers/net/ethernet/cavium/thunder/pf_locals.h | 365 +++++++++++++++++++++++ drivers/net/ethernet/cavium/thunder/pf_vf.c | 207 +++++++++++++ 3 files changed, 650 insertions(+) create mode 100644 drivers/net/ethernet/cavium/thunder/pf_globals.h create mode 100644 drivers/net/ethernet/cavium/thunder/pf_locals.h create mode 100644 drivers/net/ethernet/cavium/thunder/pf_vf.c diff --git a/drivers/net/ethernet/cavium/thunder/pf_globals.h b/drivers/net/ethernet/cavium/thunder/pf_globals.h new file mode 100644 index 0000000..79fab86 --- /dev/null +++ b/drivers/net/ethernet/cavium/thunder/pf_globals.h @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2015 Cavium, Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License + * as published by the Free Software Foundation. + */ + +#ifndef NIC_PF_H +#define NIC_PF_H + +#include +#include +#include +#include "thunder_bgx.h" +#include "tbl_access.h" + +#define TNS_MAX_LMAC 8 +#define TNS_MIN_LMAC 0 + +struct tns_global_st { + u64 magic; + char version[16]; + u64 reg_cnt; + struct table_static_s tbl_info[TNS_MAX_TABLE]; +}; + +#define PF_COUNT 3 +#define PF_1 0 +#define PF_2 64 +#define PF_3 96 +#define PF_END 128 + +int is_pf(int node_id, int vf); +int get_pf(int node_id, int vf); +void get_vf_group(int node_id, int lmac, int *start_vf, int *end_vf); +int vf_to_pport(int node_id, int vf); +int pf_filter_init(void); +int tns_init(const struct firmware *fw, struct device *dev); +void tns_exit(void); +void pf_notify_msg_handler(int node_id, void *arg); +void nic_init_pf_vf_mapping(void); +int nic_set_pf_vf_mapping(int node_id); +int get_bgx_id(int node_id, int vf_id, int *bgx_id, int *lmac); +int phy_port_to_bgx_lmac(int node, int port, int *bgx, int *lmac); +int tns_filter_valid_entry(int node, int req_type, int vf, int vlan); +void nic_enable_valid_vf(int max_vf_cnt); + +union nic_pf_qsx_rqx_bp_cfg { + u64 u; + struct nic_pf_qsx_rqx_bp_cfg_s { + u64 bpid : 8; + u64 cq_bp : 8; + u64 rbdr_bp : 8; + u64 reserved_24_61 : 38; + u64 cq_bp_ena : 1; + u64 rbdr_bp_ena : 1; + } s; +}; + +#define NIC_PF_QSX_RQX_BP_CFG 0x20010500ul +#define RBDR_CQ_BP 129 + +union nic_pf_intfx_bp_cfg { + u64 u; + struct bdk_nic_pf_intfx_bp_cfg_s { + u64 bp_id : 4; + u64 bp_type : 1; + u64 reserved_5_62 : 58; + u64 bp_ena : 1; + } s; +}; + +#define NIC_PF_INTFX_BP_CFG 0x208ull + +#define FW_NAME "tns_firmware.bin" + +#endif diff --git a/drivers/net/ethernet/cavium/thunder/pf_locals.h b/drivers/net/ethernet/cavium/thunder/pf_locals.h new file mode 100644 index 0000000..f7e74bb --- /dev/null +++ b/drivers/net/ethernet/cavium/thunder/pf_locals.h @@ -0,0 +1,365 @@ +/* + * Copyright (C) 2015 Cavium, Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License + * as published by the Free Software Foundation. + */ + +#ifndef __PF_LOCALS__ +#define __PF_LOCALS__ + +#include + +#define XP_TOTAL_PORTS (137) +#define MAX_SYS_PORTS XP_TOTAL_PORTS +//Loopback port was invalid in MAC filter design +#define TNS_MAC_FILTER_MAX_SYS_PORTS (MAX_SYS_PORTS - 1) +//Maximum LMAC available +#define TNS_MAX_INGRESS_GROUP 8 +#define TNS_MAX_VF (TNS_MAC_FILTER_MAX_SYS_PORTS - TNS_MAX_INGRESS_GROUP) +#define TNS_VLAN_FILTER_MAX_INDEX 256 +#define TNS_MAC_FILTER_MAX_INDEX 1536 +#define TNS_MAX_VLAN_PER_VF 16 + +#define TNS_NULL_VIF 152 +#define TNS_BASE_BCAST_VIF 136 +#define TNS_BASE_MCAST_VIF 144 +#define TNS_FW_MAX_SIZE 1048576 + +/* We are restricting each VF to register atmost 11 filter entries + * (including unicast & multicast) + */ +#define TNS_MAX_MAC_PER_VF 11 + +#define FERR 0 +#define FDEBUG 1 +#define FINFO 2 + +#define FILTER_DBG_GBL FERR +#define filter_dbg(dbg_lvl, fmt, args...) \ + ({ \ + if ((dbg_lvl) <= FILTER_DBG_GBL) \ + pr_info(fmt, ##args); \ + }) + +typedef u8 mac_addr_t[6]; ///< User define type for Mac Address +typedef u8 vlan_port_bitmap_t[32]; + +enum { + TNS_NO_ERR = 0, + + /* Error in indirect read watch out the status */ + TNS_ERROR_INDIRECT_READ = 4, + /* Error in indirect write watch out the status */ + TNS_ERROR_INDIRECT_WRITE = 5, + /* Data too large for Read/Write */ + TNS_ERROR_DATA_TOO_LARGE = 6, + /* Invalid arguments supplied to the IOCTL */ + TNS_ERROR_INVALID_ARG = 7, + + TNS_ERR_MAC_FILTER_INVALID_ENTRY, + TNS_ERR_MAC_FILTER_TBL_READ, + TNS_ERR_MAC_FILTER_TBL_WRITE, + TNS_ERR_MAC_EVIF_TBL_READ, + TNS_ERR_MAC_EVIF_TBL_WRITE, + + TNS_ERR_VLAN_FILTER_INVLAID_ENTRY, + TNS_ERR_VLAN_FILTER_TBL_READ, + TNS_ERR_VLAN_FILTER_TBL_WRITE, + TNS_ERR_VLAN_EVIF_TBL_READ, + TNS_ERR_VLAN_EVIF_TBL_WRITE, + + TNS_ERR_PORT_CONFIG_TBL_READ, + TNS_ERR_PORT_CONFIG_TBL_WRITE, + TNS_ERR_PORT_CONFIG_INVALID_ENTRY, + + TNS_ERR_DRIVER_READ, + TNS_ERR_DRIVER_WRITE, + + TNS_ERR_WRONG_PORT_NUMBER, + TNS_ERR_INVALID_TBL_ID, + TNS_ERR_ENTRY_NOT_FOUND, + TNS_ERR_DUPLICATE_MAC, + TNS_ERR_MAX_LIMIT, + + TNS_STATUS_NUM_ENTRIES +}; + +struct ing_grp_gblvif { + u32 ingress_grp; + u32 pf_vf; + u32 bcast_vif; + u32 mcast_vif; + u32 null_vif; + u32 is_valid; //Is this Ingress Group or LMAC is valid + u8 mcast_promis_grp[TNS_MAC_FILTER_MAX_SYS_PORTS]; + u8 valid_mcast_promis_ports; +}; + +struct vf_register_s { + int filter_index[16]; + u32 filter_count; + int vf_in_mcast_promis; + int vf_in_promis; + int vlan[TNS_MAX_VLAN_PER_VF]; + u32 vlan_count; +}; + +union mac_filter_keymask_type_s { + u64 key_value; + + struct { + u32 ingress_grp: 16; + mac_addr_t mac_DA; + } s; +}; + +struct mac_filter_keymask_s { + u8 is_valid; + union mac_filter_keymask_type_s key_type; +}; + +union mac_filter_data_s { + u64 data; + struct { + u64 evif: 16; + u64 Reserved0 : 48; + } s; +}; + +struct mac_filter_entry { + struct mac_filter_keymask_s key; + struct mac_filter_keymask_s mask; + union mac_filter_data_s data; +}; + +union vlan_filter_keymask_type_s { + u64 key_value; + + struct { + u32 ingress_grp: 16; + u32 vlan: 12; + u32 reserved: 4; + u32 reserved1; + } s; +}; + +struct vlan_filter_keymask_s { + u8 is_valid; + union vlan_filter_keymask_type_s key_type; +}; + +union vlan_filter_data_s { + u64 data; + struct { + u64 filter_idx: 16; + u64 Reserved0 : 48; + } s; +}; + +struct vlan_filter_entry { + struct vlan_filter_keymask_s key; + struct vlan_filter_keymask_s mask; + union vlan_filter_data_s data; +}; + +struct evif_entry { + u64 rsp_type: 2; + u64 truncate: 1; + u64 mtu_prf: 3; + u64 mirror_en: 1; + u64 q_mirror_en: 1; + u64 prt_bmap7_0: 8; + u64 rewrite_ptr0: 8; + u64 rewrite_ptr1: 8; + /* Byte 0 is data31_0[7:0] and byte 3 is data31_0[31:24] */ + u64 data31_0: 32; + u64 insert_ptr0: 16; + u64 insert_ptr1: 16; + u64 insert_ptr2: 16; + u64 mre_ptr: 15; + u64 prt_bmap_8: 1; + u64 prt_bmap_72_9; + u64 prt_bmap_136_73; +}; + +struct itt_entry_s { + u32 rsvd0 : 30; + u32 pkt_dir : 1; + u32 is_admin_vlan_enabled : 1; + u32 reserved0 : 6; + u32 default_evif : 8; + u32 admin_vlan : 12; + u32 Reserved1 : 6; + u32 Reserved2[6]; +}; + +static inline u64 TNS_TDMA_SST_ACC_RDATX(unsigned long param1) +{ + return 0x00000480ull + (param1 & 7) * 0x10ull; +} + +static inline u64 TNS_TDMA_SST_ACC_WDATX(unsigned long param1) +{ + return 0x00000280ull + (param1 & 7) * 0x10ull; +} + +union tns_tdma_sst_acc_cmd { + u64 u; + struct tns_tdma_sst_acc_cmd_s { + u64 reserved_0_1 : 2; + u64 addr : 30; + u64 size : 4; + u64 op : 1; + u64 go : 1; + u64 reserved_38_63 : 26; + } s; +}; + +#define TDMA_SST_ACC_CMD 0x00000270ull + +union tns_tdma_sst_acc_stat_t { + u64 u; + struct tns_tdma_sst_acc_stat_s { + u64 cmd_done : 1; + u64 error : 1; + u64 reserved_2_63 : 62; + } s; +}; + +#define TDMA_SST_ACC_STAT 0x00000470ull +#define TDMA_NB_INT_STAT 0x01000110ull + +union tns_acc_data { + u64 u; + struct tns_acc_data_s { + u64 lower32 : 32; + u64 upper32 : 32; + } s; +}; + +union tns_tdma_config { + u64 u; + struct tns_tdma_config_s { + u64 clk_ena : 1; + u64 clk_2x_ena : 1; + u64 reserved_2_3 : 2; + u64 csr_access_ena : 1; + u64 reserved_5_7 : 3; + u64 bypass0_ena : 1; + u64 bypass1_ena : 1; + u64 reserved_10_63 : 54; + } s; +}; + +#define TNS_TDMA_CONFIG_OFFSET 0x00000200ull + +union tns_tdma_cap { + u64 u; + struct tns_tdma_cap_s { + u64 switch_capable : 1; + u64 reserved_1_63 : 63; + } s; +}; + +#define TNS_TDMA_CAP_OFFSET 0x00000400ull +#define TNS_RDMA_CONFIG_OFFSET 0x00001200ull + +union tns_tdma_lmacx_config { + u64 u; + struct tns_tdma_lmacx_config_s { + u64 fifo_cdts : 14; + u64 reserved_14_63 : 50; + } s; +}; + +union _tns_sst_config { + u64 data; + struct { +#ifdef __BIG_ENDIAN + u64 powerof2stride : 1; + u64 run : 11; + u64 reserved : 14; + u64 req_type : 2; + u64 word_cnt : 4; + u64 byte_addr : 32; +#else + u64 byte_addr : 32; + u64 word_cnt : 4; + u64 req_type : 2; + u64 reserved : 14; + u64 run : 11; + u64 powerof2stride : 1; +#endif + } cmd; + struct { +#ifdef __BIG_ENDIAN + u64 do_not_copy : 26; + u64 do_copy : 38; +#else + u64 do_copy : 38; + u64 do_not_copy : 26; +#endif + } copy; + struct { +#ifdef __BIG_ENDIAN + u64 magic : 48; + u64 major_version_BCD : 8; + u64 minor_version_BCD : 8; +#else + u64 minor_version_BCD : 8; + u64 major_version_BCD : 8; + u64 magic : 48; +#endif + } header; +}; + +static inline u64 TNS_TDMA_LMACX_CONFIG_OFFSET(unsigned long param1) + __attribute__ ((pure, always_inline)); +static inline u64 TNS_TDMA_LMACX_CONFIG_OFFSET(unsigned long param1) +{ + return 0x00000300ull + (param1 & 7) * 0x10ull; +} + +#define TNS_TDMA_RESET_CTL_OFFSET 0x00000210ull + +int read_register_indirect(u64 address, u8 size, u8 *kern_buffer); +int write_register_indirect(u64 address, u8 size, u8 *kern_buffer); +int tns_write_register_indirect(int node, u64 address, u8 size, + u8 *kern_buffer); +int tns_read_register_indirect(int node, u64 address, u8 size, + u8 *kern_buffer); +u64 tns_read_register(u64 start, u64 offset); +void tns_write_register(u64 start, u64 offset, u64 data); +int tbl_write(int node, int tbl_id, int tbl_index, void *key, void *mask, + void *data); +int tbl_read(int node, int tbl_id, int tbl_index, void *key, void *mask, + void *data); +int invalidate_table_entry(int node, int tbl_id, int tbl_idx); +int alloc_table_index(int node, int table_id, int *index); +void free_table_index(int node, int table_id, int index); + +struct pf_vf_data { + int pf_id; + int num_vfs; + int lmac; + int sys_lmac; + int bgx_idx; +}; + +struct pf_vf_map_s { + bool valid; + int lmac_cnt; + struct pf_vf_data pf_vf[TNS_MAX_LMAC]; +}; + +extern struct pf_vf_map_s pf_vf_map_data[MAX_NUMNODES]; +int tns_enable_mcast_promis(int node, int vf); +int filter_tbl_lookup(int node, int tblid, void *entry, int *idx); + +#define MCAST_PROMIS(a, b, c) ingressgrp_gblvif[(a)][(b)].mcast_promis_grp[(c)] +#define VALID_MCAST_PROMIS(a, b) \ + ingressgrp_gblvif[(a)][(b)].valid_mcast_promis_ports + +#endif /*__PF_LOCALS__*/ diff --git a/drivers/net/ethernet/cavium/thunder/pf_vf.c b/drivers/net/ethernet/cavium/thunder/pf_vf.c new file mode 100644 index 0000000..bc4f923 --- /dev/null +++ b/drivers/net/ethernet/cavium/thunder/pf_vf.c @@ -0,0 +1,207 @@ +/* + * Copyright (C) 2015 Cavium, Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License + * as published by the Free Software Foundation. + */ + +#include "nic_reg.h" +#include "nic.h" +#include "pf_globals.h" +#include "pf_locals.h" + +#define PFVF_DAT(gidx, lidx) \ + pf_vf_map_data[gidx].pf_vf[lidx] + +struct pf_vf_map_s pf_vf_map_data[MAX_NUMNODES]; + +void nic_init_pf_vf_mapping(void) +{ + int i; + + for (i = 0 ; i < MAX_NUMNODES; i++) { + pf_vf_map_data[i].lmac_cnt = 0; + pf_vf_map_data[i].valid = false; + } +} + +/* Based on available LMAC's we create physical group called ingress group + * Designate first VF as acted PF of this group, called PfVf interface. + */ +static inline void set_pf_vf_global_data(int node, int valid_vf_cnt) +{ + unsigned int bgx_map; + int bgx; + int lmac, lmac_cnt = 0; + + if (pf_vf_map_data[node].valid) + return; + + bgx_map = bgx_get_map(node); + for (bgx = 0; bgx < MAX_BGX_PER_CN88XX; bgx++) { + if (!(bgx_map & (1 << bgx))) + continue; + pf_vf_map_data[node].valid = true; + lmac_cnt = bgx_get_lmac_count(node, bgx); + + for (lmac = 0; lmac < lmac_cnt; lmac++) { + int slc = lmac + pf_vf_map_data[node].lmac_cnt; + + PFVF_DAT(node, slc).pf_id = (bgx * 64) + (lmac * + valid_vf_cnt); + PFVF_DAT(node, slc).num_vfs = valid_vf_cnt; + PFVF_DAT(node, slc).lmac = lmac; + PFVF_DAT(node, slc).bgx_idx = bgx; + PFVF_DAT(node, slc).sys_lmac = bgx * MAX_LMAC_PER_BGX + + lmac; + } + pf_vf_map_data[node].lmac_cnt += lmac_cnt; + } +} + +/* We have 2 NIC pipes in each node.Each NIC pipe associated with BGX interface + * Each BGX contains atmost 4 LMACs (or PHY's) and supports 64 VF's + * Hardware doesn't have any physical PF, one of VF acts as PF. + */ +int nic_set_pf_vf_mapping(int node_id) +{ + unsigned int bgx_map; + int node = 0; + int bgx; + int lmac_cnt = 0, valid_vf_cnt = 64; + + do { + bgx_map = bgx_get_map(node); + /* Calculate Maximum VF's in each physical port group */ + for (bgx = 0; bgx < MAX_BGX_PER_CN88XX; bgx++) { + if (!(bgx_map & (1 << bgx))) + continue; + lmac_cnt = bgx_get_lmac_count(node, bgx); + //Maximum 64 VF's for each BGX + if (valid_vf_cnt > (64 / lmac_cnt)) + valid_vf_cnt = (64 / lmac_cnt); + } + } while (++node < nr_node_ids); + + nic_enable_valid_vf(valid_vf_cnt); + node = 0; + do { + set_pf_vf_global_data(node, valid_vf_cnt); + } while (++node < nr_node_ids); + + return 0; +} + +/* Find if VF is a acted PF */ +int is_pf(int node, int vf) +{ + int i; + + /* Invalid Request, Init not done properly */ + if (!pf_vf_map_data[node].valid) + return 0; + + for (i = 0; i < pf_vf_map_data[node].lmac_cnt; i++) + if (vf == PFVF_DAT(node, i).pf_id) + return 1; + + return 0; +} + +/* Get the acted PF corresponding to this VF */ +int get_pf(int node, int vf) +{ + int i; + + /* Invalid Request, Init not done properly */ + if (!pf_vf_map_data[node].valid) + return 0; + + for (i = 0; i < pf_vf_map_data[node].lmac_cnt; i++) + if ((vf >= PFVF_DAT(node, i).pf_id) && + (vf < (PFVF_DAT(node, i).pf_id + + PFVF_DAT(node, i).num_vfs))) + return pf_vf_map_data[node].pf_vf[i].pf_id; + + return -1; +} + +/* Get the starting vf and ending vf number of the LMAC group */ +void get_vf_group(int node, int lmac, int *start_vf, int *end_vf) +{ + int i; + + /* Invalid Request, Init not done properly */ + if (!pf_vf_map_data[node].valid) + return; + + for (i = 0; i < pf_vf_map_data[node].lmac_cnt; i++) { + if (lmac == (PFVF_DAT(node, i).sys_lmac)) { + *start_vf = PFVF_DAT(node, i).pf_id; + *end_vf = PFVF_DAT(node, i).pf_id + + PFVF_DAT(node, i).num_vfs; + return; + } + } +} + +/* Get the physical port # of the given vf */ +int vf_to_pport(int node, int vf) +{ + int i; + + /* Invalid Request, Init not done properly */ + if (!pf_vf_map_data[node].valid) + return 0; + + for (i = 0; i < pf_vf_map_data[node].lmac_cnt; i++) + if ((vf >= PFVF_DAT(node, i).pf_id) && + (vf < (PFVF_DAT(node, i).pf_id + + PFVF_DAT(node, i).num_vfs))) + return PFVF_DAT(node, i).sys_lmac; + + return -1; +} + +/* Get BGX # and LMAC # corresponding to VF */ +int get_bgx_id(int node, int vf, int *bgx_idx, int *lmac) +{ + int i; + + /* Invalid Request, Init not done properly */ + if (!pf_vf_map_data[node].valid) + return 1; + + for (i = 0; i < pf_vf_map_data[node].lmac_cnt; i++) { + if ((vf >= PFVF_DAT(node, i).pf_id) && + (vf < (PFVF_DAT(node, i).pf_id + + PFVF_DAT(node, i).num_vfs))) { + *bgx_idx = pf_vf_map_data[node].pf_vf[i].bgx_idx; + *lmac = pf_vf_map_data[node].pf_vf[i].lmac; + return 0; + } + } + + return 1; +} + +/* Get BGX # and LMAC # corresponding to physical port */ +int phy_port_to_bgx_lmac(int node, int port, int *bgx, int *lmac) +{ + int i; + + /* Invalid Request, Init not done properly */ + if (!pf_vf_map_data[node].valid) + return 1; + + for (i = 0; i < pf_vf_map_data[node].lmac_cnt; i++) { + if (port == (PFVF_DAT(node, i).sys_lmac)) { + *bgx = pf_vf_map_data[node].pf_vf[i].bgx_idx; + *lmac = pf_vf_map_data[node].pf_vf[i].lmac; + return 0; + } + } + + return 1; +} -- 1.8.3.1