genode_c_api/nic_client: add link_state support

Support for the link state signal was missing.

issue #5471
This commit is contained in:
Sebastian Sumpf 2025-01-19 19:16:06 +01:00 committed by Norman Feske
parent 488fcfd1a3
commit 67c7313f5e
2 changed files with 27 additions and 5 deletions

View File

@ -29,6 +29,7 @@ extern "C" {
*/
void genode_nic_client_init(struct genode_env *,
struct genode_allocator *,
struct genode_signal_handler *,
struct genode_signal_handler *);
/**
@ -54,11 +55,17 @@ void genode_nic_client_destroy(struct genode_nic_client *);
*************/
/**
* Retreive MAC address from server
* Retrieve MAC address from server
*/
struct genode_mac_address genode_nic_client_mac_address(struct genode_nic_client *);
/**
* Retrieve link state
*/
bool genode_nic_client_link_state(struct genode_nic_client *);
/**********************************************
** Transmit packets towards the NIC session **
**********************************************/

View File

@ -25,6 +25,7 @@ struct Statics
Env *env_ptr;
Allocator *alloc_ptr;
Signal_context_capability sigh { };
Signal_context_capability link_sigh { };
Registry<Registered<genode_nic_client>> nic_clients { };
};
@ -58,12 +59,15 @@ struct genode_nic_client : private Noncopyable, private Interface
public:
genode_nic_client(Env &env, Allocator &alloc, Signal_context_capability sigh,
Session_label const &session_label)
genode_nic_client(Env &env, Allocator &alloc,
Signal_context_capability sigh,
Signal_context_capability link_sigh,
Session_label const &session_label)
:
_env(env), _alloc(alloc),
_session_label(session_label)
{
_connection.link_state_sigh(link_sigh);
_connection.rx_channel()->sigh_ready_to_ack (sigh);
_connection.rx_channel()->sigh_packet_avail (sigh);
_connection.tx_channel()->sigh_ack_avail (sigh);
@ -179,16 +183,20 @@ struct genode_nic_client : private Noncopyable, private Interface
}
Nic::Mac_address mac_address() { return _connection.mac_address(); }
bool link_state() { return _connection.link_state(); }
};
void genode_nic_client_init(genode_env *env_ptr,
genode_allocator *alloc_ptr,
genode_signal_handler *sigh_ptr)
genode_signal_handler *sigh_ptr,
genode_signal_handler *link_sig_ptr)
{
statics().env_ptr = env_ptr;
statics().alloc_ptr = alloc_ptr;
statics().sigh = cap(sigh_ptr);
statics().link_sigh = cap(link_sig_ptr);
}
@ -210,6 +218,12 @@ genode_mac_address genode_nic_client_mac_address(genode_nic_client *nic_client_p
}
bool genode_nic_client_link_state(genode_nic_client *nic_client_ptr)
{
return nic_client_ptr->link_state();
}
bool genode_nic_client_tx_packet(genode_nic_client *nic_client_ptr,
genode_nic_client_tx_packet_content_t tx_packet_content_cb,
genode_nic_client_tx_packet_context *ctx_ptr)
@ -237,7 +251,8 @@ struct genode_nic_client *genode_nic_client_create(char const *label)
return new (*statics().alloc_ptr)
Registered<genode_nic_client>(statics().nic_clients, *statics().env_ptr,
*statics().alloc_ptr, statics().sigh,
*statics().alloc_ptr,
statics().sigh, statics().link_sigh,
Session_label(label));
}