mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-10-29 17:54:14 +08:00
Merge pull request #691 from hlyi/clean-min-max-port
clean up min_port and max_port from struct after PR#684
This commit is contained in:
5 files changed
+13
-18
No files matched your search
@@ -38,8 +38,8 @@ existing files as the template:
|
|||||||
```
|
```
|
||||||
|
|
||||||
`MACHINE_CHIPSET` is `RTL8373` or `RTL8372`; a build without it will fail. It selects the default
|
`MACHINE_CHIPSET` is `RTL8373` or `RTL8372`; a build without it will fail. It selects the default
|
||||||
logical port range: `min_port` is `0` for RTL8373 and `3` for RTL8372, while `max_port` is `8`,
|
logical port range: `MACHINE_MIN_PORT` is `0` for RTL8373 and `3` for RTL8372, while
|
||||||
the highest logical port index. A board with a different range defines
|
`MACHINE_MAX_PORT` is `8`, the highest logical port index. A board with a different range defines
|
||||||
`MACHINE_MIN_PORT` and/or `MACHINE_MAX_PORT` in its header to override the
|
`MACHINE_MIN_PORT` and/or `MACHINE_MAX_PORT` in its header to override the
|
||||||
defaults.
|
defaults.
|
||||||
|
|
||||||
@@ -94,16 +94,16 @@ __code const struct machine machine = {
|
|||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
`MACHINE_COMMON_SETTING` (from `machine_defs.h`) initializes `machine_name`,
|
`MACHINE_COMMON_SETTING` (from `machine_defs.h`) initializes `machine_name` and
|
||||||
`isRTL8373`, `min_port` and `max_port` from the header's `MACHINE_MODEL` and
|
`isRTL8373` from the header's `MACHINE_MODEL` and `MACHINE_CHIPSET`. The logical
|
||||||
`MACHINE_CHIPSET`. Keep it as the first initializer and list the
|
port range comes from `MACHINE_MIN_PORT` and `MACHINE_MAX_PORT` in `machine.h`.
|
||||||
board-specific fields after it.
|
Keep it as the first initializer and list the board-specific fields after it.
|
||||||
|
|
||||||
### Fields
|
### Fields
|
||||||
|
|
||||||
| Field | Meaning |
|
| Field | Meaning |
|
||||||
|-------|---------|
|
|-------|---------|
|
||||||
| `MACHINE_COMMON_SETTING` | expands to `machine_name` (`MACHINE_MODEL`), `isRTL8373` (`1` for `RTL8373`, `0` for `RTL8372`), `min_port` and `max_port`; all are derived from the header's `MACHINE_CHIPSET` (see Step 1) |
|
| `MACHINE_COMMON_SETTING` | expands to `machine_name` (`MACHINE_MODEL`) and `isRTL8373` (`1` for `RTL8373`, `0` for `RTL8372`); both are derived from the header's `MACHINE_CHIPSET` (see Step 1) |
|
||||||
| `n_sfp` | number of SFP+ cages |
|
| `n_sfp` | number of SFP+ cages |
|
||||||
| `n_10g` | SerDes 10G capability used by the RTL837xN init: `0` none, `1` one, `2` two 10G-capable SerDes |
|
| `n_10g` | SerDes 10G capability used by the RTL837xN init: `0` none, `1` one, `2` two 10G-capable SerDes |
|
||||||
| `log_to_phys_port[9]` | logical port (0-based index) → physical front-panel port number |
|
| `log_to_phys_port[9]` | logical port (0-based index) → physical front-panel port number |
|
||||||
|
|||||||
@@ -84,10 +84,6 @@ struct sfp_port
|
|||||||
struct machine {
|
struct machine {
|
||||||
char machine_name[30];
|
char machine_name[30];
|
||||||
uint8_t isRTL8373;
|
uint8_t isRTL8373;
|
||||||
// Lowest logical port number
|
|
||||||
uint8_t min_port;
|
|
||||||
// Highest logical port number
|
|
||||||
uint8_t max_port;
|
|
||||||
uint8_t n_sfp;
|
uint8_t n_sfp;
|
||||||
uint8_t n_10g;
|
uint8_t n_10g;
|
||||||
uint8_t log_to_phys_port[9];
|
uint8_t log_to_phys_port[9];
|
||||||
|
|||||||
@@ -43,8 +43,6 @@
|
|||||||
|
|
||||||
#define MACHINE_COMMON_SETTING \
|
#define MACHINE_COMMON_SETTING \
|
||||||
.machine_name = MACHINE_MODEL, \
|
.machine_name = MACHINE_MODEL, \
|
||||||
.isRTL8373 = MACHINE_CHIPSET == RTL8373, \
|
.isRTL8373 = MACHINE_CHIPSET == RTL8373
|
||||||
.min_port = MACHINE_MIN_PORT, \
|
|
||||||
.max_port = MACHINE_MAX_PORT
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -59,8 +59,6 @@ uint8_t *hex = (uint8_t *)hex_chars;
|
|||||||
/* ---- a 9-port RTL8373 whose logical ports map to themselves ---- */
|
/* ---- a 9-port RTL8373 whose logical ports map to themselves ---- */
|
||||||
const struct machine machine = {
|
const struct machine machine = {
|
||||||
.machine_name = "HOSTTEST",
|
.machine_name = "HOSTTEST",
|
||||||
.min_port = 0,
|
|
||||||
.max_port = 8,
|
|
||||||
.n_sfp = 0,
|
.n_sfp = 0,
|
||||||
.log_to_phys_port = { 1, 2, 3, 4, 5, 6, 7, 8, 9 },
|
.log_to_phys_port = { 1, 2, 3, 4, 5, 6, 7, 8, 9 },
|
||||||
.phys_to_log_port = { 0, 1, 2, 3, 4, 5, 6, 7, 8 },
|
.phys_to_log_port = { 0, 1, 2, 3, 4, 5, 6, 7, 8 },
|
||||||
|
|||||||
+5
-2
@@ -14,8 +14,11 @@
|
|||||||
uint8_t uip_buf[UIP_CONF_BUFFER_ALLOC_SIZE];
|
uint8_t uip_buf[UIP_CONF_BUFFER_ALLOC_SIZE];
|
||||||
uint16_t uip_len;
|
uint16_t uip_len;
|
||||||
struct uip_eth_addr uip_ethaddr = { .addr = {0x02,0x11,0x22,0x33,0x44,0x55} };
|
struct uip_eth_addr uip_ethaddr = { .addr = {0x02,0x11,0x22,0x33,0x44,0x55} };
|
||||||
const struct machine machine = { .min_port = 0, .max_port = 7,
|
const struct machine machine = {
|
||||||
.log_to_phys_port = {5, 1, 2, 3, 4, 6, 7, 8, 9} };
|
.log_to_phys_port = {5, 1, 2, 3, 4, 6, 7, 8, 9} };
|
||||||
|
/* Logical ports of the mock machine above */
|
||||||
|
#define TEST_MIN_PORT 0
|
||||||
|
#define TEST_MAX_PORT 7
|
||||||
struct machine_runtime machine_detected = { .isRTL8373 = 1 };
|
struct machine_runtime machine_detected = { .isRTL8373 = 1 };
|
||||||
uint8_t lacpEnabled;
|
uint8_t lacpEnabled;
|
||||||
uint16_t management_vlan; /* mocked; slow-protocol path zeroes it per-frame */
|
uint16_t management_vlan; /* mocked; slow-protocol path zeroes it per-frame */
|
||||||
@@ -216,7 +219,7 @@ int main(int argc, char **argv)
|
|||||||
lacp_lag_set(0, 0x00ff);
|
lacp_lag_set(0, 0x00ff);
|
||||||
step(8);
|
step(8);
|
||||||
int all_tx = 1, sane = 1;
|
int all_tx = 1, sane = 1;
|
||||||
for (int i = machine.min_port; i <= machine.max_port; i++) {
|
for (int i = TEST_MIN_PORT; i <= TEST_MAX_PORT; i++) {
|
||||||
if (!tx_count[i]) all_tx = 0;
|
if (!tx_count[i]) all_tx = 0;
|
||||||
if (last_tx[i].ethertype != HTONS(0x8809) || last_tx[i].subtype != 1
|
if (last_tx[i].ethertype != HTONS(0x8809) || last_tx[i].subtype != 1
|
||||||
|| last_tx[i].dst[5] != 0x02
|
|| last_tx[i].dst[5] != 0x02
|
||||||
|
|||||||
Reference in new issue
Block a user