]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[xfer] Add xfer_window_changed()
authorMichael Brown <mcb30@ipxe.org>
Sun, 5 Sep 2010 00:16:29 +0000 (01:16 +0100)
committerMichael Brown <mcb30@ipxe.org>
Sun, 5 Sep 2010 02:12:17 +0000 (03:12 +0100)
xfer_window_changed() can be used to notify peers that an interface is
now ready to accept data.  This can potentially be used to eliminate
the need for wasteful processes that simply poll xfer_window() until
the window becomes non-zero.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/core/xfer.c
src/include/ipxe/xfer.h

index 222af52a83d4905a2abce23b55b77fbe67db80d5..a755d438a350b8f6a0849d20994850ed2460a8cd 100644 (file)
@@ -104,6 +104,33 @@ size_t xfer_window ( struct interface *intf ) {
        return len;
 }
 
+/**
+ * Report change of flow control window
+ *
+ * @v intf             Data transfer interface
+ *
+ * Note that this method is used to indicate only unsolicited changes
+ * in the flow control window.  In particular, this method must not be
+ * called as part of the response to xfer_deliver(), since that could
+ * easily lead to an infinite loop.  Callers of xfer_deliver() should
+ * assume that the flow control window will have changed without
+ * generating an xfer_window_changed() message.
+ */
+void xfer_window_changed ( struct interface *intf ) {
+       struct interface *dest;
+       xfer_window_changed_TYPE ( void * ) *op =
+               intf_get_dest_op ( intf, xfer_window_changed, &dest );
+       void *object = intf_object ( dest );
+
+       if ( op ) {
+               op ( object );
+       } else {
+               /* Default is to do nothing */
+       }
+
+       intf_put ( dest );
+}
+
 /**
  * Allocate I/O buffer
  *
index 2aa35f8def2a40d009d469dafb800531d05fb1fe..0c0303279fc20c25fb7a7eaaee84895f4234b876 100644 (file)
@@ -57,6 +57,10 @@ extern size_t xfer_window ( struct interface *intf );
 #define xfer_window_TYPE( object_type ) \
        typeof ( size_t ( object_type ) )
 
+extern void xfer_window_changed ( struct interface *intf );
+#define xfer_window_changed_TYPE( object_type ) \
+       typeof ( void ( object_type ) )
+
 extern struct io_buffer * xfer_alloc_iob ( struct interface *intf,
                                           size_t len );
 #define xfer_alloc_iob_TYPE( object_type ) \