Skip to content

Commit 1418988

Browse files
ZhaoxiangJinmmahadevan108
authored andcommitted
sdk_ng: Add missing netc files to hal_nxp
Signed-off-by: Zhaoxiang Jin <[email protected]>
1 parent ef3238c commit 1418988

File tree

6 files changed

+740
-0
lines changed

6 files changed

+740
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright 2024 NXP
3+
*
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
*/
6+
7+
#include "fsl_netc_soc.h"
8+
9+
/*! @brief Pointers to enetc si bases for each instance. */
10+
static ENETC_SI_Type *const s_enetcSiBases[] = ENETC_SI_BASE_PTRS;
11+
12+
/*! @brief Pointers to netc bases for each instance. */
13+
static ENETC_PCI_TYPE0_Type *const s_netcBases[] = ENETC_PCI_TYPE0_BASE_PTRS;
14+
15+
/*! @brief Pointers to netc vf bases for each instance. */
16+
static ENETC_VF_PCI_TYPE0_Type *const s_netcVfBases[] = ENETC_VF_PCI_TYPE0_BASE_PTRS;
17+
18+
/*! @brief Pointers to enetc bases for each instance. */
19+
static NETC_ENETC_Type *const s_netcEnetcBases[] = NETC_ENETC_BASE_PTRS;
20+
21+
void NETC_SocGetBaseResource(netc_enetc_hw_t *hw, netc_hw_si_idx_t si)
22+
{
23+
uint8_t instance = getSiInstance(si);
24+
uint8_t siNum = getSiNum(si);
25+
uint8_t siIdx = getSiIdx(si);
26+
27+
hw->si = s_enetcSiBases[siIdx];
28+
hw->base = s_netcEnetcBases[instance];
29+
hw->common = (NETC_SW_ENETC_Type *)((uintptr_t)hw->base + 0x1000U);
30+
hw->portGroup.port = (NETC_PORT_Type *)((uintptr_t)hw->base + 0x4000U);
31+
hw->portGroup.eth = (NETC_ETH_LINK_Type *)((uintptr_t)hw->base + 0x5000U);
32+
hw->global = (ENETC_GLOBAL_Type *)((uintptr_t)hw->base + 0x10000U);
33+
if (siNum == 0U)
34+
{
35+
hw->func.pf = s_netcBases[1 + siIdx];
36+
hw->msixTable = (netc_msix_entry_t *)((uintptr_t)hw->si + 0x30000U);
37+
}
38+
else
39+
{
40+
hw->func.vf = s_netcVfBases[siIdx - 3];
41+
hw->msixTable = (netc_msix_entry_t *)((uintptr_t)hw->si + 0x60000U);
42+
}
43+
}
44+
45+
uint32_t NETC_SocGetFuncInstance(netc_hw_eth_port_idx_t port)
46+
{
47+
uint32_t instance = (uint32_t)port + 1U;
48+
49+
return instance;
50+
}
51+
52+
status_t NETC_SocPreInitVsi(netc_enetc_hw_t *hw, netc_hw_si_idx_t si)
53+
{
54+
return kStatus_Success;
55+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
* Copyright 2024 NXP
3+
*
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
*/
6+
7+
#ifndef _FSL_NETC_SOC_H_
8+
#define _FSL_NETC_SOC_H_
9+
10+
#include "netc_hw/fsl_netc_hw.h"
11+
12+
#define TMR_PCI_HDR_TYPE0 TMR0_PCI_HDR_TYPE0
13+
#define EMDIO_PCI_HDR_TYPE0 EMDIO0_PCI_HDR_TYPE0
14+
15+
/*! @brief Switch port numbers(Port0 ~ 3 in Switch Core). */
16+
#define NETC_SOC_SWT_PORT_NUM (4U)
17+
18+
/*! @brief The Switch function register base address offset.(SW0_PCI_HDR_TYPE0) */
19+
#define NETC_SOC_SWT_PCIE_FUNC_OFFSET (5U)
20+
21+
/*! @brief Station interface index enumerator */
22+
typedef enum _netc_hw_si_idx
23+
{
24+
kNETC_ENETC0PSI0 = (0U << 8U) | (0U << 4U) | 0U, /*!< ENETC0 PSI0, index 0 */
25+
kNETC_ENETC1PSI0 = (1U << 8U) | (0U << 4U) | 1U, /*!< ENETC1 PSI0, index 1 */
26+
kNETC_ENETC2PSI0 = (2U << 8U) | (0U << 4U) | 2U, /*!< ENETC2 PSI0, index 2 */
27+
kNETC_ENETC3PSI0 = (3U << 8U) | (0U << 4U) | 3U, /*!< ENETC3 PSI0, index 3 */
28+
kNETC_ENETC3VSI1 = (3U << 8U) | (1U << 4U) | 4U, /*!< ENETC3 VSI1, index 4 */
29+
kNETC_ENETC3VSI2 = (3U << 8U) | (2U << 4U) | 5U, /*!< ENETC3 VSI2, index 5 */
30+
kNETC_ENETC3VSI3 = (3U << 8U) | (3U << 4U) | 6U, /*!< ENETC3 VSI3, index 6 */
31+
} netc_hw_si_idx_t;
32+
33+
/*! @brief Ethernet MAC port resource for the NETC module */
34+
typedef enum _netc_hw_eth_port_idx
35+
{
36+
kNETC_ENETC0EthPort = 0U, /*!< Ethernet MAC port3(Eth2) for ENETC0 */
37+
kNETC_ENETC1EthPort = 1U, /*!< Ethernet MAC port4(Eth3) for ENETC1 */
38+
kNETC_ENETC2EthPort = 2U, /*!< Ethernet MAC port5(Eth4) for ENETC2 */
39+
kNETC_SWITCH0EthPort0 = 3U, /*!< Ethernet MAC port0(Eth0) for SWITCH */
40+
kNETC_SWITCH0EthPort1 = 4U, /*!< Ethernet MAC port1(Eth1) for SWITCH */
41+
kNETC_SWITCH0EthPort2 = 5U, /*!< Ethernet MAC port2(Eth2) for SWITCH */
42+
} netc_hw_eth_port_idx_t;
43+
44+
/*!
45+
* @brief Enumeration for NETC timer external trigger index
46+
*/
47+
typedef enum _netc_timer_exttrig_index
48+
{
49+
kNETC_TimerExtTrig1 = 0,
50+
kNETC_TimerExtTrig2,
51+
} netc_timer_exttrig_index_t;
52+
53+
/*!
54+
* @brief Get register map resource
55+
*
56+
* @param handle The enetc hw handle.
57+
* @param si The SI object.
58+
*/
59+
void NETC_SocGetBaseResource(netc_enetc_hw_t *hw, netc_hw_si_idx_t si);
60+
61+
/*!
62+
* @brief Get func instance from mac port
63+
*
64+
* @param port The enetc mac port.
65+
* @return uint32_t
66+
*/
67+
uint32_t NETC_SocGetFuncInstance(netc_hw_eth_port_idx_t port);
68+
69+
/*!
70+
* @brief Preinit VSIs
71+
*
72+
* @param hw The enetc hw handle.
73+
* @param si The SI object.
74+
* @return status_t
75+
*/
76+
status_t NETC_SocPreInitVsi(netc_enetc_hw_t *hw, netc_hw_si_idx_t si);
77+
#endif /* _FSL_NETC_SOC_H_ */
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
/*
2+
* Copyright 2023 NXP
3+
*
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
*/
6+
7+
#include "fsl_netc_soc.h"
8+
9+
/*! @brief Pointers to enetc si bases for each instance. */
10+
static ENETC_SI_Type *const s_enetcSiBases[] = ENETC_SI_BASE_PTRS;
11+
12+
/*! @brief Pointers to netc bases for each instance. */
13+
static ENETC_PCI_TYPE0_Type *const s_netcBases[] = ENETC_PCI_TYPE0_BASE_PTRS;
14+
15+
/*! @brief Pointers to netc vf bases for each instance. */
16+
static ENETC_VF_PCI_TYPE0_Type *const s_netcVfBases[] = ENETC_VF_PCI_TYPE0_BASE_PTRS;
17+
18+
/*! @brief Pointers to enetc bases for each instance. */
19+
static NETC_ENETC_Type *const s_netcEnetcBases[] = NETC_ENETC_BASE_PTRS;
20+
21+
void NETC_SocGetBaseResource(netc_enetc_hw_t *hw, netc_hw_si_idx_t si)
22+
{
23+
uint8_t instance = getSiInstance(si);
24+
uint8_t siNum = getSiNum(si);
25+
uint8_t siIdx = getSiIdx(si);
26+
27+
hw->si = s_enetcSiBases[siIdx];
28+
hw->base = s_netcEnetcBases[instance];
29+
hw->common = (NETC_SW_ENETC_Type *)((uintptr_t)hw->base + 0x1000U);
30+
hw->portGroup.port = (NETC_PORT_Type *)((uintptr_t)hw->base + 0x4000U);
31+
hw->portGroup.eth = (NETC_ETH_LINK_Type *)((uintptr_t)hw->base + 0x5000U);
32+
hw->global = (ENETC_GLOBAL_Type *)((uintptr_t)hw->base + 0x10000U);
33+
if (siNum == 0U)
34+
{
35+
hw->func.pf = s_netcBases[1U + siIdx];
36+
hw->msixTable = (netc_msix_entry_t *)((uintptr_t)hw->si + 0x30000U);
37+
}
38+
else
39+
{
40+
hw->func.vf = s_netcVfBases[siIdx - 3U];
41+
hw->msixTable = (netc_msix_entry_t *)((uintptr_t)hw->si + 0x60000U);
42+
}
43+
}
44+
45+
uint32_t NETC_SocGetFuncInstance(netc_hw_eth_port_idx_t port)
46+
{
47+
uint32_t instance = (uint32_t)port + 1U;
48+
49+
return instance;
50+
}
51+
52+
status_t NETC_SocPreInitVsi(netc_enetc_hw_t *hw, netc_hw_si_idx_t si)
53+
{
54+
uint8_t macAddr0[] = { 0x00, 0x00, 0xfa, 0xfa, 0xdd, 0xa0 };
55+
uint8_t macAddr1[] = { 0x00, 0x00, 0xfa, 0xfa, 0xdd, 0xa1 };
56+
netc_hw_enetc_si_config_t vsi0Config = {
57+
.txRingUse = 3U, .rxRingUse = 3U, .vlanCtrl = (uint32_t)kNETC_ENETC_StanCVlan | (uint32_t)kNETC_ENETC_StanSVlan};
58+
netc_hw_enetc_si_config_t vsi1Config = {
59+
.txRingUse = 4U, .rxRingUse = 4U, .vlanCtrl = (uint32_t)kNETC_ENETC_StanCVlan | (uint32_t)kNETC_ENETC_StanSVlan};
60+
netc_si_l2vf_config_t vlanConfig = {
61+
.acceptUntagged = true, .enPromis = true, .useOuterVlanTag = true};
62+
uint32_t vsi0MsixNum = 4U;
63+
uint32_t vsi1MsixNum = 5U;
64+
uint8_t vsi0Num;
65+
uint8_t vsi1Num;
66+
status_t result;
67+
68+
switch (si)
69+
{
70+
case kNETC_ENETC0PSI0:
71+
vsi0Num = getSiNum(kNETC_ENETC0VSI0);
72+
vsi1Num = getSiNum(kNETC_ENETC0VSI1);
73+
break;
74+
case kNETC_ENETC1PSI0:
75+
vsi0Num = getSiNum(kNETC_ENETC1VSI0);
76+
vsi1Num = getSiNum(kNETC_ENETC1VSI1);
77+
break;
78+
case kNETC_ENETC2PSI0:
79+
vsi0Num = getSiNum(kNETC_ENETC2VSI0);
80+
vsi1Num = getSiNum(kNETC_ENETC2VSI1);
81+
break;
82+
default:
83+
assert(false);
84+
break;
85+
}
86+
87+
/* RSS key init with generated random values */
88+
hw->base->PRSSKR0 = 0x995770eaU;
89+
hw->base->PRSSKR1 = 0x7e8cbbe3U;
90+
hw->base->PRSSKR2 = 0x9ac8285bU;
91+
hw->base->PRSSKR3 = 0xce20c189U;
92+
hw->base->PRSSKR4 = 0xb7ece3ebU;
93+
hw->base->PRSSKR5 = 0xf8bc2513U;
94+
hw->base->PRSSKR6 = 0x62613353U;
95+
hw->base->PRSSKR7 = 0x4c84ae76U;
96+
hw->base->PRSSKR8 = 0x72c890f1U;
97+
hw->base->PRSSKR9 = 0xd7a8144bU;
98+
99+
/* Preinit vsi0 for mac address, BDR num, and MSIX interrupt num */
100+
NETC_EnetcSetSIMacAddr(hw->base, vsi0Num, macAddr0);
101+
102+
result = NETC_EnetcSetMsixEntryNum(hw->base, vsi0Num, vsi0MsixNum);
103+
if (result != kStatus_Success)
104+
{
105+
return result;
106+
}
107+
108+
result = NETC_EnetcConfigureSI(hw->base, vsi0Num, &vsi0Config);
109+
if (result != kStatus_Success)
110+
{
111+
return result;
112+
}
113+
114+
NETC_EnetcEnableSI(hw->base, vsi0Num, true);
115+
116+
/* Preinit vsi1 for mac address, BDR num, and MSIX interrupt num */
117+
NETC_EnetcSetSIMacAddr(hw->base, vsi1Num, macAddr1);
118+
119+
result = NETC_EnetcSetMsixEntryNum(hw->base, vsi1Num, vsi1MsixNum);
120+
if (result != kStatus_Success)
121+
{
122+
return result;
123+
}
124+
125+
result = NETC_EnetcConfigureSI(hw->base, vsi1Num, &vsi1Config);
126+
if (result != kStatus_Success)
127+
{
128+
return result;
129+
}
130+
131+
NETC_EnetcEnableSI(hw->base, vsi1Num, true);
132+
133+
NETC_EnetcConfigureVlanFilter(hw->base, getSiNum(si), &vlanConfig);
134+
return result;
135+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
* Copyright 2023 NXP
3+
*
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
*/
6+
7+
#ifndef _FSL_NETC_SOC_H_
8+
#define _FSL_NETC_SOC_H_
9+
10+
#include "netc_hw/fsl_netc_hw.h"
11+
#include "netc_hw/fsl_netc_hw_enetc.h"
12+
#include "netc_hw/fsl_netc_hw_si.h"
13+
14+
#define TMR_PCI_HDR_TYPE0 TMR0_PCI_HDR_TYPE0
15+
#define EMDIO_PCI_HDR_TYPE0 EMDIO0_PCI_HDR_TYPE0
16+
17+
/*! @brief Station interface index enumerator */
18+
typedef enum _netc_hw_si_idx
19+
{
20+
kNETC_ENETC0PSI0 = (0U << 8U) | (0U << 4U) | 0U, /*!< ENETC0 PSI0, index 0 */
21+
kNETC_ENETC1PSI0 = (1U << 8U) | (0U << 4U) | 1U, /*!< ENETC1 PSI0, index 1 */
22+
kNETC_ENETC2PSI0 = (2U << 8U) | (0U << 4U) | 2U, /*!< ENETC2 PSI0, index 2 */
23+
kNETC_ENETC0VSI0 = (0U << 8U) | (1U << 4U) | 3U, /*!< ENETC0 VSI0, index 3 */
24+
kNETC_ENETC1VSI0 = (1U << 8U) | (1U << 4U) | 4U, /*!< ENETC1 VSI0, index 4 */
25+
kNETC_ENETC2VSI0 = (2U << 8U) | (1U << 4U) | 5U, /*!< ENETC2 VSI0, index 5 */
26+
kNETC_ENETC0VSI1 = (0U << 8U) | (2U << 4U) | 6U, /*!< ENETC0 VSI1, index 6 */
27+
kNETC_ENETC1VSI1 = (1U << 8U) | (2U << 4U) | 7U, /*!< ENETC1 VSI1, index 7 */
28+
kNETC_ENETC2VSI1 = (2U << 8U) | (2U << 4U) | 8U, /*!< ENETC2 VSI1, index 8 */
29+
} netc_hw_si_idx_t;
30+
31+
/*! @brief Ethernet MAC port resource for the NETC module */
32+
typedef enum _netc_hw_eth_port_idx
33+
{
34+
kNETC_ENETC0EthPort = 0U, /*!< Ethernet MAC port for ENETC0 */
35+
kNETC_ENETC1EthPort = 1U, /*!< Ethernet MAC port for ENETC1 */
36+
kNETC_ENETC2EthPort = 2U, /*!< Ethernet MAC port for ENETC2 */
37+
} netc_hw_eth_port_idx_t;
38+
39+
/*!
40+
* @brief Enumeration for NETC timer external trigger index
41+
*/
42+
typedef enum _netc_timer_exttrig_index
43+
{
44+
kNETC_TimerExtTrig1 = 0,
45+
kNETC_TimerExtTrig2,
46+
} netc_timer_exttrig_index_t;
47+
48+
/*!
49+
* @brief Get register map resource
50+
*
51+
* @param handle The enetc hw handle.
52+
* @param si The SI object.
53+
*/
54+
void NETC_SocGetBaseResource(netc_enetc_hw_t *hw, netc_hw_si_idx_t si);
55+
56+
/*!
57+
* @brief Get func instance from mac port
58+
*
59+
* @param port The enetc mac port.
60+
* @return uint32_t
61+
*/
62+
uint32_t NETC_SocGetFuncInstance(netc_hw_eth_port_idx_t port);
63+
64+
/*!
65+
* @brief Preinit VSIs
66+
*
67+
* @param hw The enetc hw handle.
68+
* @param si The SI object.
69+
* @return status_t
70+
*/
71+
status_t NETC_SocPreInitVsi(netc_enetc_hw_t *hw, netc_hw_si_idx_t si);
72+
#endif /* _FSL_NETC_SOC_H_ */

0 commit comments

Comments
 (0)