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:
feelfree69 authored and GitHub committed 2026-10-23 08:08:14 +02:00
commit 2d0abbbca0
5 files changed
+13 -18

No files matched your search

+7 -7
View File
@@ -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
logical port range: `min_port` is `0` for RTL8373 and `3` for RTL8372, while `max_port` is `8`,
the highest logical port index. A board with a different range defines
logical port range: `MACHINE_MIN_PORT` is `0` for RTL8373 and `3` for RTL8372, while
`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
defaults.
@@ -94,16 +94,16 @@ __code const struct machine machine = {
};
```
`MACHINE_COMMON_SETTING` (from `machine_defs.h`) initializes `machine_name`,
`isRTL8373`, `min_port` and `max_port` from the header's `MACHINE_MODEL` and
`MACHINE_CHIPSET`. Keep it as the first initializer and list the
board-specific fields after it.
`MACHINE_COMMON_SETTING` (from `machine_defs.h`) initializes `machine_name` and
`isRTL8373` from the header's `MACHINE_MODEL` and `MACHINE_CHIPSET`. The logical
port range comes from `MACHINE_MIN_PORT` and `MACHINE_MAX_PORT` in `machine.h`.
Keep it as the first initializer and list the board-specific fields after it.
### Fields
| 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_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 |
-4
View File
@@ -84,10 +84,6 @@ struct sfp_port
struct machine {
char machine_name[30];
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_10g;
uint8_t log_to_phys_port[9];
+1 -3
View File
@@ -43,8 +43,6 @@
#define MACHINE_COMMON_SETTING \
.machine_name = MACHINE_MODEL, \
.isRTL8373 = MACHINE_CHIPSET == RTL8373, \
.min_port = MACHINE_MIN_PORT, \
.max_port = MACHINE_MAX_PORT
.isRTL8373 = MACHINE_CHIPSET == RTL8373
#endif
-2
View File
@@ -59,8 +59,6 @@ uint8_t *hex = (uint8_t *)hex_chars;
/* ---- a 9-port RTL8373 whose logical ports map to themselves ---- */
const struct machine machine = {
.machine_name = "HOSTTEST",
.min_port = 0,
.max_port = 8,
.n_sfp = 0,
.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 },
+5 -2
View File
@@ -14,8 +14,11 @@
uint8_t uip_buf[UIP_CONF_BUFFER_ALLOC_SIZE];
uint16_t uip_len;
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} };
/* Logical ports of the mock machine above */
#define TEST_MIN_PORT 0
#define TEST_MAX_PORT 7
struct machine_runtime machine_detected = { .isRTL8373 = 1 };
uint8_t lacpEnabled;
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);
step(8);
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 (last_tx[i].ethertype != HTONS(0x8809) || last_tx[i].subtype != 1
|| last_tx[i].dst[5] != 0x02