1 /* 2 * Copyright (c) 2021 HiSilicon (Shanghai) Technologies CO., LIMITED. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef HIETH_H 17 #define HIETH_H 18 19 #include <osal_spinlock.h> 20 #include <los_event.h> 21 #include "eth_device.h" 22 23 #ifdef __cplusplus 24 #if __cplusplus 25 extern "C" { 26 #endif /* __cplusplus */ 27 #endif /* __cplusplus */ 28 29 #define HIETH_TSO_SUPPORTED 30 #define CONFIG_HIETH_HWQ_XMIT_DEPTH 12 31 #define HIETH_HWQ_TXQ_SIZE (2 * CONFIG_HIETH_HWQ_XMIT_DEPTH) 32 33 /* Interface Mode definitions */ 34 typedef enum { 35 PHY_INTERFACE_MODE_MII, 36 PHY_INTERFACE_MODE_RMII, 37 PHY_INTERFACE_MODE_MAX, 38 } PhyInterfaceMode; 39 40 /* port */ 41 #define UP_PORT 0 42 #define DOWN_PORT 1 43 44 struct TxPktInfo { 45 union { 46 struct { 47 uint32_t dataLen : 11; 48 uint32_t nfragsNum : 5; 49 uint32_t protHdrLen : 4; 50 uint32_t ipHdrLen : 4; 51 uint32_t reserved : 2; 52 uint32_t sgFlag : 1; 53 uint32_t coeFlag : 1; 54 uint32_t portType : 1; 55 uint32_t ipVer : 1; 56 uint32_t vlanFlag : 1; 57 uint32_t tsoFlag : 1; 58 } info; 59 uint32_t val; 60 } tx; 61 uint32_t txAddr; /* normal pkt: data buffer, sg pkt: sg desc buffer */ 62 uint32_t sgDescOffset; /* TSO pkt, desc addr */ 63 }; 64 65 struct HiethNetdevLocal { 66 #ifdef HIETH_TSO_SUPPORTED 67 uint32_t sgHead; 68 uint32_t sgTail; 69 #endif 70 char *iobase; /* virtual io addr */ 71 unsigned long iobasePhys; /* physical io addr */ 72 uint8_t port; /* 0 => up port, 1 => down port */ 73 74 #ifdef HIETH_TSO_SUPPORTED 75 struct TxPktInfo *txq; 76 uint32_t txqHead; 77 uint32_t txqTail; 78 int32_t qSize; 79 #endif 80 int32_t txHwCnt; 81 82 struct { 83 int32_t hwXmitq; 84 } depth; 85 86 #define SKB_SIZE (HIETH_MAX_FRAME_SIZE) 87 uint32_t phyId; 88 uint32_t mdioFrqdiv; 89 int32_t linkStat; 90 int32_t txBusy; 91 92 int32_t phyMode; 93 int32_t phyAddr; 94 OsalSpinlock tx_lock; 95 OsalSpinlock rx_lock; 96 }; 97 98 /* hieth context */ 99 struct HiethPlatformData { 100 struct HiethNetdevLocal stNetdevLocal; 101 EVENT_CB_S stEvent; 102 }; 103 104 struct HiethPlatformData *GetHiethPlatformData(void); 105 struct HiethNetdevLocal *GetHiethNetDevLocal(struct EthDevice *ethDevice); 106 107 #ifdef __cplusplus 108 #if __cplusplus 109 } 110 #endif /* __cplusplus */ 111 #endif /* __cplusplus */ 112 113 #endif /* HIETH_H */ 114