]> git.karo-electronics.de Git - karo-tx-uboot.git/blobdiff - include/net.h
dm: eth: Provide a way for drivers to manage packet buffers
[karo-tx-uboot.git] / include / net.h
index 39d28492bab4e67d4a494558047cfe8429f45386..ef9de3cad14bce2844b4f4647e0b665ab832665d 100644 (file)
@@ -95,7 +95,14 @@ struct eth_pdata {
  *
  * start: Prepare the hardware to send and receive packets
  * send: Send the bytes passed in "packet" as a packet on the wire
- * recv: Check if the hardware received a packet. Call the network stack if so
+ * recv: Check if the hardware received a packet. If so, set the pointer to the
+ *      packet buffer in the packetp parameter. If not, return an error or 0 to
+ *      indicate that the hardware receive FIFO is empty. If 0 is returned, the
+ *      network stack will not process the empty packet, but free_pkt() will be
+ *      called if supplied
+ * free_pkt: Give the driver an opportunity to manage its packet buffer memory
+ *          when the network stack is finished processing it. This will only be
+ *          called when no error was returned from recv - optional
  * stop: Stop the hardware from looking for packets - may be called even if
  *      state == PASSIVE
  * mcast: Join or leave a multicast group (for TFTP) - optional
@@ -110,7 +117,8 @@ struct eth_pdata {
 struct eth_ops {
        int (*start)(struct udevice *dev);
        int (*send)(struct udevice *dev, void *packet, int length);
-       int (*recv)(struct udevice *dev);
+       int (*recv)(struct udevice *dev, uchar **packetp);
+       int (*free_pkt)(struct udevice *dev, uchar *packet, int length);
        void (*stop)(struct udevice *dev);
 #ifdef CONFIG_MCAST_TFTP
        int (*mcast)(struct udevice *dev, const u8 *enetaddr, int join);
@@ -122,6 +130,11 @@ struct eth_ops {
 #define eth_get_ops(dev) ((struct eth_ops *)(dev)->driver->ops)
 
 struct udevice *eth_get_dev(void); /* get the current device */
+/*
+ * The devname can be either an exact name given by the driver or device tree
+ * or it can be an alias of the form "eth%d"
+ */
+struct udevice *eth_get_dev_by_name(const char *devname);
 unsigned char *eth_get_ethaddr(void); /* get the current device MAC */
 /* Used only when NetConsole is enabled */
 int eth_init_state_only(void); /* Set active state */
@@ -536,7 +549,7 @@ int NetLoop(enum proto_t);
 void   NetStop(void);
 
 /* Load failed.         Start again. */
-void   NetStartAgain(void);
+int    NetStartAgain(void);
 
 /* Get size of the ethernet header when we send */
 int    NetEthHdrSize(void);
@@ -606,6 +619,7 @@ static inline void net_set_state(enum net_loop_state state)
 /* Transmit a packet */
 static inline void NetSendPacket(uchar *pkt, int len)
 {
+       /* Currently no way to return errors from eth_send() */
        (void) eth_send(pkt, len);
 }