From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7A1EAA04AC; Tue, 1 Sep 2020 13:52:23 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7D9D61C115; Tue, 1 Sep 2020 13:51:19 +0200 (CEST) Received: from smtpbgau1.qq.com (smtpbgau1.qq.com [54.206.16.166]) by dpdk.org (Postfix) with ESMTP id B77A51C07B for ; Tue, 1 Sep 2020 13:51:13 +0200 (CEST) X-QQ-mid: bizesmtp5t1598961067tsm3fgw2a Received: from localhost.localdomain.com (unknown [183.129.236.74]) by esmtp6.qq.com (ESMTP) with id ; Tue, 01 Sep 2020 19:51:07 +0800 (CST) X-QQ-SSF: 01400000000000B0C000000A0000000 X-QQ-FEAT: CBgi6aaeY4fjkGs94fdrpygIRqa9YCOyyVpCr+u/7F28VjCQhQN5VS9tdmuEK y7nwHJlpnfhLJRxiTdUxzW2w1rXnP+EHBjIv/V/Za1m/W+bSaW8YNXFmryZBGC0dTLn0Isa Idmwb/ztXIGDDZR+p7TcW91Gcjn1mMsoLF70okuuHAPARzsIVdgdFYjmr2KE2+ED94nnWr/ nKDXxYKTAJJedieLGu+DVSshmaxJpUEKRwpg/PLPdLF3XZAkhB658SKLOW3V4zDfLb2ihrl dJUCeS/bP2UGGk/QgQ3BlF+hdGT3slAqhrcwmtUVmHizWl2Ts+vtoRMxmMez96FCT2TQlih Mpr+1iccuw0TmHDHIEIJPR8cEBoJg== X-QQ-GoodBg: 2 From: Jiawen Wu To: dev@dpdk.org Cc: Jiawen Wu Date: Tue, 1 Sep 2020 19:50:36 +0800 Message-Id: <20200901115113.1529675-5-jiawenwu@trustnetic.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20200901115113.1529675-1-jiawenwu@trustnetic.com> References: <20200901115113.1529675-1-jiawenwu@trustnetic.com> X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:trustnetic.com:qybgforeign:qybgforeign6 X-QQ-Bgrelay: 1 Subject: [dpdk-dev] [PATCH v1 05/42] net/txgbe: add mac type and HW ops dummy X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add base driver shared code from dummy function. Signed-off-by: Jiawen Wu --- drivers/net/txgbe/base/meson.build | 1 + drivers/net/txgbe/base/txgbe_hw.c | 90 ++++++++++++++++++++++++++++- drivers/net/txgbe/base/txgbe_hw.h | 3 +- drivers/net/txgbe/base/txgbe_type.h | 3 + drivers/net/txgbe/base/txgbe_vf.c | 14 +++++ drivers/net/txgbe/base/txgbe_vf.h | 12 ++++ 6 files changed, 121 insertions(+), 2 deletions(-) create mode 100644 drivers/net/txgbe/base/txgbe_vf.c create mode 100644 drivers/net/txgbe/base/txgbe_vf.h diff --git a/drivers/net/txgbe/base/meson.build b/drivers/net/txgbe/base/meson.build index 72f1e73c9..1cce9b679 100644 --- a/drivers/net/txgbe/base/meson.build +++ b/drivers/net/txgbe/base/meson.build @@ -4,6 +4,7 @@ sources = [ 'txgbe_eeprom.c', 'txgbe_hw.c', + 'txgbe_vf.c', ] error_cflags = ['-Wno-unused-value', diff --git a/drivers/net/txgbe/base/txgbe_hw.c b/drivers/net/txgbe/base/txgbe_hw.c index 17ccd0b65..5ff3983d9 100644 --- a/drivers/net/txgbe/base/txgbe_hw.c +++ b/drivers/net/txgbe/base/txgbe_hw.c @@ -3,6 +3,7 @@ */ #include "txgbe_type.h" +#include "txgbe_vf.h" #include "txgbe_eeprom.h" #include "txgbe_hw.h" @@ -19,12 +20,99 @@ s32 txgbe_set_rar(struct txgbe_hw *hw, u32 index, u8 *addr, u32 vmdq, } s32 txgbe_init_shared_code(struct txgbe_hw *hw) +{ + s32 status; + + DEBUGFUNC("txgbe_init_shared_code"); + + /* + * Set the mac type + */ + txgbe_set_mac_type(hw); + + txgbe_init_ops_dummy(hw); + switch (hw->mac.type) { + case txgbe_mac_raptor: + status = txgbe_init_ops_pf(hw); + break; + case txgbe_mac_raptor_vf: + status = txgbe_init_ops_vf(hw); + break; + default: + status = TXGBE_ERR_DEVICE_NOT_SUPPORTED; + break; + } + hw->mac.max_link_up_time = TXGBE_LINK_UP_TIME; + + hw->bus.set_lan_id(hw); + + return status; + +} + +/** + * txgbe_set_mac_type - Sets MAC type + * @hw: pointer to the HW structure + * + * This function sets the mac type of the adapter based on the + * vendor ID and device ID stored in the hw structure. + **/ +s32 txgbe_set_mac_type(struct txgbe_hw *hw) +{ + s32 err = 0; + + DEBUGFUNC("txgbe_set_mac_type\n"); + + if (hw->vendor_id != PCI_VENDOR_ID_WANGXUN) { + DEBUGOUT("Unsupported vendor id: %x", hw->vendor_id); + return TXGBE_ERR_DEVICE_NOT_SUPPORTED; + } + + switch (hw->device_id) { + case TXGBE_DEV_ID_RAPTOR_KR_KX_KX4: + hw->mac.type = txgbe_mac_raptor; + break; + case TXGBE_DEV_ID_RAPTOR_XAUI: + case TXGBE_DEV_ID_RAPTOR_SGMII: + hw->mac.type = txgbe_mac_raptor; + break; + case TXGBE_DEV_ID_RAPTOR_SFP: + case TXGBE_DEV_ID_WX1820_SFP: + hw->mac.type = txgbe_mac_raptor; + break; + case TXGBE_DEV_ID_RAPTOR_QSFP: + hw->mac.type = txgbe_mac_raptor; + break; + case TXGBE_DEV_ID_RAPTOR_VF: + case TXGBE_DEV_ID_RAPTOR_VF_HV: + hw->mac.type = txgbe_mac_raptor_vf; + break; + default: + err = TXGBE_ERR_DEVICE_NOT_SUPPORTED; + DEBUGOUT("Unsupported device id: %x", hw->device_id); + break; + } + + DEBUGOUT("txgbe_set_mac_type found mac: %d, returns: %d\n", + hw->mac.type, err); + return err; +} + +s32 txgbe_init_hw(struct txgbe_hw *hw) { RTE_SET_USED(hw); return 0; } -s32 txgbe_init_hw(struct txgbe_hw *hw) + +/** + * txgbe_init_ops_pf - Inits func ptrs and MAC type + * @hw: pointer to hardware structure + * + * Initialize the function pointers and assign the MAC type. + * Does not touch the hardware. + **/ +s32 txgbe_init_ops_pf(struct txgbe_hw *hw) { RTE_SET_USED(hw); return 0; diff --git a/drivers/net/txgbe/base/txgbe_hw.h b/drivers/net/txgbe/base/txgbe_hw.h index cd738245f..adcc5fc48 100644 --- a/drivers/net/txgbe/base/txgbe_hw.h +++ b/drivers/net/txgbe/base/txgbe_hw.h @@ -12,5 +12,6 @@ s32 txgbe_init_hw(struct txgbe_hw *hw); s32 txgbe_set_rar(struct txgbe_hw *hw, u32 index, u8 *addr, u32 vmdq, u32 enable_addr); s32 txgbe_init_shared_code(struct txgbe_hw *hw); - +s32 txgbe_set_mac_type(struct txgbe_hw *hw); +s32 txgbe_init_ops_pf(struct txgbe_hw *hw); #endif /* _TXGBE_HW_H_ */ diff --git a/drivers/net/txgbe/base/txgbe_type.h b/drivers/net/txgbe/base/txgbe_type.h index 1264a83d9..5524e5de0 100644 --- a/drivers/net/txgbe/base/txgbe_type.h +++ b/drivers/net/txgbe/base/txgbe_type.h @@ -5,6 +5,8 @@ #ifndef _TXGBE_TYPE_H_ #define _TXGBE_TYPE_H_ +#define TXGBE_LINK_UP_TIME 90 /* 9.0 Seconds */ + #define TXGBE_ALIGN 128 /* as intel did */ #include "txgbe_status.h" @@ -316,6 +318,7 @@ struct txgbe_mac_info { u8 san_addr[ETH_ADDR_LEN]; u32 num_rar_entries; + u32 max_link_up_time; }; struct txgbe_phy_info { diff --git a/drivers/net/txgbe/base/txgbe_vf.c b/drivers/net/txgbe/base/txgbe_vf.c new file mode 100644 index 000000000..d96b57ec6 --- /dev/null +++ b/drivers/net/txgbe/base/txgbe_vf.c @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2015-2020 + */ + +#include "txgbe_type.h" +#include "txgbe_vf.h" + +s32 txgbe_init_ops_vf(struct txgbe_hw *hw) +{ + RTE_SET_USED(hw); + + return 0; +} + diff --git a/drivers/net/txgbe/base/txgbe_vf.h b/drivers/net/txgbe/base/txgbe_vf.h new file mode 100644 index 000000000..9572845c8 --- /dev/null +++ b/drivers/net/txgbe/base/txgbe_vf.h @@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2015-2020 + */ + +#ifndef _TXGBE_VF_H_ +#define _TXGBE_VF_H_ + +#include "txgbe_type.h" + +s32 txgbe_init_ops_vf(struct txgbe_hw *hw); + +#endif /* __TXGBE_VF_H__ */ -- 2.18.4