1
0
mirror of https://github.com/DigitalDevices/octonet.git synced 2023-10-10 13:36:52 +02:00

add set_entry function

This commit is contained in:
rjkm 2021-01-18 16:18:06 +01:00
parent 35aedfcc4c
commit 105792f885

View File

@ -105,6 +105,27 @@ int mdio_close(int fd)
close(fd); close(fd);
} }
int switch_set_entry(uint8_t mac[6], uint8_t vec, uint8_t type)
{
int fd = mdio_open();
dbgprintf(DEBUG_SWITCH, "switch_set_entry %02x:%02x:%02x:%02x:%02x:%02x = %02x %02x\n",
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], vec, type);
if (fd < 0)
return -1;
if (vec)
mdio_writereg(fd, 0x1b, 0x0c, (vec << 4) | type);
else
mdio_writereg(fd, 0x1b, 0x0c, 0);
mdio_writereg(fd, 0x1b, 0x0d, ((uint16_t) mac[0] << 8) | mac[1]);
mdio_writereg(fd, 0x1b, 0x0e, ((uint16_t) mac[2] << 8) | mac[3]);
mdio_writereg(fd, 0x1b, 0x0f, ((uint16_t) mac[4] << 8) | mac[5]);
mdio_writereg(fd, 0x1b, 0x0b, 0xb000);
mdio_wait_switch(fd, 0x1b, 0x0b);
mdio_close(fd);
return 0;
}
int switch_get_port(uint8_t mac[6]) int switch_get_port(uint8_t mac[6])
{ {
int fd = mdio_open(); int fd = mdio_open();
@ -149,6 +170,7 @@ int switch_get_port(uint8_t mac[6])
return -1; return -1;
} }
int switch_set_multicast(uint8_t mac[6], uint8_t vec) int switch_set_multicast(uint8_t mac[6], uint8_t vec)
{ {
int fd = mdio_open(); int fd = mdio_open();