Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/nic/include/nic.h

    r00d7e1b r77ad86c  
    4242#include <ddf/driver.h>
    4343#include <device/hw_res_parsed.h>
    44 #include <net/packet.h>
    4544#include <ops/nic.h>
     45
     46#define DEVICE_CATEGORY_NIC "nic"
    4647
    4748struct nic;
     
    6162
    6263/**
    63  * Simple structure for sending the allocated frames (packets) in a list.
     64 * Simple structure for sending lists of frames.
    6465 */
    6566typedef struct {
    6667        link_t link;
    67         packet_t *packet;
     68        void *data;
     69        size_t size;
    6870} nic_frame_t;
    6971
     
    7173
    7274/**
    73  * Handler for writing packet data to the NIC device.
    74  * The function is responsible for releasing the packet.
     75 * Handler for writing frame data to the NIC device.
     76 * The function is responsible for releasing the frame.
    7577 * It does not return anything, if some error is detected the function just
    7678 * silently fails (logging on debug level is suggested).
    7779 *
    7880 * @param nic_data
    79  * @param packet        Pointer to the packet to be sent
    80  */
    81 typedef void (*write_packet_handler)(nic_t *, packet_t *);
     81 * @param data          Pointer to frame data
     82 * @param size          Size of frame data in bytes
     83 */
     84typedef void (*send_frame_handler)(nic_t *, void *, size_t);
     85
    8286/**
    8387 * The handler for transitions between driver states.
     
    9195 */
    9296typedef int (*state_change_handler)(nic_t *);
     97
    9398/**
    9499 * Handler for unicast filtering mode change.
     
    103108 */
    104109typedef int (*unicast_mode_change_handler)(nic_t *,
    105         nic_unicast_mode_t, const nic_address_t *, size_t);
     110    nic_unicast_mode_t, const nic_address_t *, size_t);
     111
    106112/**
    107113 * Handler for multicast filtering mode change.
     
    116122 */
    117123typedef int (*multicast_mode_change_handler)(nic_t *,
    118         nic_multicast_mode_t, const nic_address_t *, size_t);
     124    nic_multicast_mode_t, const nic_address_t *, size_t);
     125
    119126/**
    120127 * Handler for broadcast filtering mode change.
     
    127134 */
    128135typedef int (*broadcast_mode_change_handler)(nic_t *, nic_broadcast_mode_t);
     136
    129137/**
    130138 * Handler for blocked sources list change.
     
    135143 */
    136144typedef void (*blocked_sources_change_handler)(nic_t *,
    137         const nic_address_t *, size_t);
     145    const nic_address_t *, size_t);
     146
    138147/**
    139148 * Handler for VLAN filtering mask change.
     
    142151 */
    143152typedef void (*vlan_mask_change_handler)(nic_t *, const nic_vlan_mask_t *);
     153
    144154/**
    145155 * Handler called when a WOL virtue is added.
     
    157167 * @return ENOTSUP      If this filter cannot work on this NIC (e.g. the NIC
    158168 *                                      cannot run in promiscuous node or the limit of WOL
    159  *                                      packets' specifications was reached).
     169 *                                      frames' specifications was reached).
    160170 * @return ELIMIT       If this filter must implemented in HW but currently the
    161171 *                                      limit of these HW filters was reached.
    162172 */
    163173typedef int (*wol_virtue_add_handler)(nic_t *, const nic_wol_virtue_t *);
     174
    164175/**
    165176 * Handler called when a WOL virtue is removed.
     
    171182 */
    172183typedef void (*wol_virtue_remove_handler)(nic_t *, const nic_wol_virtue_t *);
     184
    173185/**
    174186 * Handler for poll mode change.
     
    183195 */
    184196typedef int (*poll_mode_change_handler)(nic_t *,
    185         nic_poll_mode_t, const struct timeval *);
     197    nic_poll_mode_t, const struct timeval *);
     198
    186199/**
    187200 * Event handler called when the NIC should poll its buffers for a new frame
     
    199212extern int nic_driver_init(const char *);
    200213extern void nic_driver_implement(driver_ops_t *, ddf_dev_ops_t *,
    201         nic_iface_t *);
     214    nic_iface_t *);
    202215
    203216/* Functions called in add_device */
    204217extern int nic_connect_to_services(nic_t *);
    205 extern int nic_register_as_ddf_fun(nic_t *, ddf_dev_ops_t *);
    206218extern int nic_get_resources(nic_t *, hw_res_list_parsed_t *);
    207219extern void nic_set_specific(nic_t *, void *);
    208 extern void nic_set_write_packet_handler(nic_t *, write_packet_handler);
     220extern void nic_set_send_frame_handler(nic_t *, send_frame_handler);
    209221extern void nic_set_state_change_handlers(nic_t *,
    210         state_change_handler, state_change_handler, state_change_handler);
     222    state_change_handler, state_change_handler, state_change_handler);
    211223extern void nic_set_filtering_change_handlers(nic_t *,
    212         unicast_mode_change_handler, multicast_mode_change_handler,
    213         broadcast_mode_change_handler, blocked_sources_change_handler,
    214         vlan_mask_change_handler);
     224    unicast_mode_change_handler, multicast_mode_change_handler,
     225    broadcast_mode_change_handler, blocked_sources_change_handler,
     226    vlan_mask_change_handler);
    215227extern void nic_set_wol_virtue_change_handlers(nic_t *,
    216         wol_virtue_add_handler, wol_virtue_remove_handler);
     228    wol_virtue_add_handler, wol_virtue_remove_handler);
    217229extern void nic_set_poll_handlers(nic_t *,
    218         poll_mode_change_handler, poll_request_handler);
    219 
    220 /* Functions called in device_added */
    221 extern int nic_ready(nic_t *);
     230    poll_mode_change_handler, poll_request_handler);
    222231
    223232/* General driver functions */
    224233extern ddf_dev_t *nic_get_ddf_dev(nic_t *);
    225234extern ddf_fun_t *nic_get_ddf_fun(nic_t *);
     235extern void nic_set_ddf_fun(nic_t *, ddf_fun_t *);
    226236extern nic_t *nic_get_from_ddf_dev(ddf_dev_t *);
    227237extern nic_t *nic_get_from_ddf_fun(ddf_fun_t *);
     
    232242extern int nic_report_poll_mode(nic_t *, nic_poll_mode_t, struct timeval *);
    233243extern void nic_query_address(nic_t *, nic_address_t *);
    234 extern void nic_received_packet(nic_t *, packet_t *);
    235 extern void nic_received_noneth_packet(nic_t *, packet_t *);
    236244extern void nic_received_frame(nic_t *, nic_frame_t *);
    237245extern void nic_received_frame_list(nic_t *, nic_frame_list_t *);
     
    247255extern void nic_report_collisions(nic_t *, unsigned);
    248256
    249 /* Packet / frame / frame list allocation and deallocation */
    250 extern packet_t *nic_alloc_packet(nic_t *, size_t);
    251 extern void nic_release_packet(nic_t *, packet_t *);
     257/* Frame / frame list allocation and deallocation */
    252258extern nic_frame_t *nic_alloc_frame(nic_t *, size_t);
    253259extern nic_frame_list_t *nic_alloc_frame_list(void);
     
    258264extern void nic_report_hw_filtering(nic_t *, int, int, int);
    259265extern void nic_query_unicast(const nic_t *,
    260         nic_unicast_mode_t *, size_t, nic_address_t *, size_t *);
     266    nic_unicast_mode_t *, size_t, nic_address_t *, size_t *);
    261267extern void nic_query_multicast(const nic_t *,
    262         nic_multicast_mode_t *, size_t, nic_address_t *, size_t *);
     268    nic_multicast_mode_t *, size_t, nic_address_t *, size_t *);
    263269extern void nic_query_broadcast(const nic_t *, nic_broadcast_mode_t *);
    264270extern void nic_query_blocked_sources(const nic_t *,
    265         size_t, nic_address_t *, size_t *);
     271    size_t, nic_address_t *, size_t *);
    266272extern int nic_query_vlan_mask(const nic_t *, nic_vlan_mask_t *);
    267273extern int nic_query_wol_max_caps(const nic_t *, nic_wv_type_t);
     
    274280extern void nic_sw_period_stop(nic_t *);
    275281
    276 /* Packet DMA lock */
    277 extern void * nic_dma_lock_packet(packet_t * packet);
    278 extern void nic_dma_unlock_packet(packet_t * packet);
    279 
    280282#endif // __NIC_H__
    281283
Note: See TracChangeset for help on using the changeset viewer.