[lib][minip] add an arg to the ethernet transmit callback
Already had the registration hook for it, but was never used.
This commit is contained in:
@@ -511,18 +511,15 @@ status_t e1000::init_device(pci_location_t loc, const e1000_id_features *id) {
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
static int e1000_tx(pktbuf_t *p) {
|
||||
if (the_e) {
|
||||
the_e->tx(p);
|
||||
}
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
status_t e1000_register_with_minip() {
|
||||
auto tx_routine = [](void *arg, pktbuf_t *p) {
|
||||
auto *e = static_cast<e1000 *>(arg);
|
||||
return e->tx(p);
|
||||
};
|
||||
|
||||
if (the_e) {
|
||||
minip_set_eth(e1000_tx, the_e, the_e->mac_addr());
|
||||
minip_set_eth(tx_routine, the_e, the_e->mac_addr());
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,5 +20,5 @@ int virtio_net_found(void);
|
||||
status_t virtio_net_get_mac_addr(uint8_t mac_addr[6]);
|
||||
|
||||
struct pktbuf;
|
||||
extern status_t virtio_net_send_minip_pkt(struct pktbuf *p);
|
||||
extern status_t virtio_net_send_minip_pkt(void *arg, struct pktbuf *p);
|
||||
|
||||
|
||||
@@ -426,7 +426,7 @@ status_t virtio_net_get_mac_addr(uint8_t mac_addr[6]) {
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
status_t virtio_net_send_minip_pkt(pktbuf_t *p) {
|
||||
status_t virtio_net_send_minip_pkt(void *arg, pktbuf_t *p) {
|
||||
LTRACEF("p %p, dlen %u, flags 0x%x\n", p, p->dlen, p->flags);
|
||||
|
||||
DEBUG_ASSERT(p && p->dlen);
|
||||
|
||||
@@ -139,7 +139,7 @@ int arp_send_request(uint32_t addr) {
|
||||
minip_get_macaddr(arp->sha);
|
||||
mac_addr_copy(arp->tha, bcast_mac);
|
||||
|
||||
minip_tx_handler(p);
|
||||
minip_tx_handler(minip_tx_arg, p);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ __BEGIN_CDECLS
|
||||
#define IPV4_BCAST (0xFFFFFFFF)
|
||||
#define IPV4_NONE (0)
|
||||
|
||||
typedef int (*tx_func_t)(pktbuf_t *p);
|
||||
typedef int (*tx_func_t)(void *arg, pktbuf_t *p);
|
||||
typedef void (*udp_callback_t)(void *data, size_t len,
|
||||
uint32_t srcaddr, uint16_t srcport, void *arg);
|
||||
|
||||
|
||||
@@ -87,6 +87,8 @@ enum {
|
||||
};
|
||||
|
||||
extern tx_func_t minip_tx_handler;
|
||||
extern void *minip_tx_arg;
|
||||
|
||||
typedef struct udp_hdr udp_hdr_t;
|
||||
static const uint8_t bcast_mac[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
|
||||
typedef uint32_t ipv4_addr;
|
||||
|
||||
@@ -209,7 +209,7 @@ static int send_arp_request(uint32_t addr) {
|
||||
mac_addr_copy(arp->sha, minip_mac);
|
||||
mac_addr_copy(arp->tha, bcast_mac);
|
||||
|
||||
minip_tx_handler(p);
|
||||
minip_tx_handler(minip_tx_arg, p);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -283,7 +283,7 @@ ready:
|
||||
minip_build_mac_hdr(eth, dst_mac, ETH_TYPE_IPV4);
|
||||
minip_build_ipv4_hdr(ip, dest_addr, proto, data_len);
|
||||
|
||||
minip_tx_handler(p);
|
||||
minip_tx_handler(minip_tx_arg, p);
|
||||
|
||||
err:
|
||||
return ret;
|
||||
@@ -320,7 +320,7 @@ static void send_ping_reply(uint32_t ipaddr, struct icmp_pkt *req, size_t reqdat
|
||||
icmp->chksum = 0;
|
||||
icmp->chksum = rfc1701_chksum((uint8_t *) icmp, len);
|
||||
|
||||
minip_tx_handler(p);
|
||||
minip_tx_handler(minip_tx_arg, p);
|
||||
}
|
||||
|
||||
static void dump_ipv4_addr(uint32_t addr) {
|
||||
@@ -459,7 +459,7 @@ __NO_INLINE static int handle_arp_pkt(pktbuf_t *p) {
|
||||
mac_addr_copy(rarp->tha, arp->sha);
|
||||
rarp->tpa = arp->spa;
|
||||
|
||||
minip_tx_handler(rp);
|
||||
minip_tx_handler(minip_tx_arg, rp);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -150,7 +150,7 @@ status_t udp_send_iovec(const iovec_t *iov, uint iov_count, udp_socket_t *handle
|
||||
|
||||
LTRACEF("packet paylod len %ld\n", len);
|
||||
|
||||
minip_tx_handler(p);
|
||||
minip_tx_handler(minip_tx_arg, p);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -320,7 +320,7 @@ static int eth_rx_worker(void *arg) {
|
||||
|
||||
#if WITH_LIB_MINIP
|
||||
|
||||
status_t stm32_eth_send_minip_pkt(pktbuf_t *p) {
|
||||
status_t stm32_eth_send_minip_pkt(void *arg, pktbuf_t *p) {
|
||||
LTRACEF("p %p, dlen %zu, eof %u\n", p, p->dlen, p->flags & PKTBUF_FLAG_EOF);
|
||||
|
||||
DEBUG_ASSERT(p && p->dlen);
|
||||
|
||||
@@ -20,5 +20,5 @@ typedef enum {
|
||||
struct pktbuf;
|
||||
|
||||
status_t eth_init(const uint8_t *mac_addr, eth_phy_itf eth_phy);
|
||||
status_t stm32_eth_send_minip_pkt(struct pktbuf *p);
|
||||
status_t stm32_eth_send_minip_pkt(void *arg, struct pktbuf *p);
|
||||
|
||||
|
||||
@@ -169,7 +169,7 @@ static void queue_pkts_in_tx_tbl(void) {
|
||||
gem.regs->net_ctrl |= NET_CTRL_START_TX;
|
||||
}
|
||||
|
||||
int gem_send_raw_pkt(struct pktbuf *p) {
|
||||
int gem_send_raw_pkt(void *arg, struct pktbuf *p) {
|
||||
status_t ret = NO_ERROR;
|
||||
|
||||
if (!p || !p->dlen) {
|
||||
@@ -557,7 +557,7 @@ static int cmd_gem(int argc, const console_cmd_args *argv) {
|
||||
p->dlen = argv[3].u;
|
||||
while (iter--) {
|
||||
memset(p->data, iter, 12);
|
||||
gem_send_raw_pkt(p);
|
||||
gem_send_raw_pkt(NULL, p);
|
||||
}
|
||||
} else if (strncmp(argv[1].str, "status", sizeof("status")) == 0) {
|
||||
uint32_t mac_top = gem.regs->spec_addr1_top;
|
||||
|
||||
@@ -7,7 +7,7 @@ typedef void (*gem_cb_t)(struct pktbuf *p);
|
||||
status_t gem_init(uintptr_t regsbase);
|
||||
void gem_set_callback(gem_cb_t rx);
|
||||
void gem_set_macaddr(uint8_t mac[6]);
|
||||
int gem_send_raw_pkt(struct pktbuf *p);
|
||||
int gem_send_raw_pkt(void *arg, struct pktbuf *p);
|
||||
|
||||
void gem_disable(void);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user