Browse Source

[xfer] Add xfer_window_changed()

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>
tags/v1.20.1
Michael Brown 13 years ago
parent
commit
c8199aacaa
2 changed files with 31 additions and 0 deletions
  1. 27
    0
      src/core/xfer.c
  2. 4
    0
      src/include/ipxe/xfer.h

+ 27
- 0
src/core/xfer.c View File

@@ -104,6 +104,33 @@ size_t xfer_window ( struct interface *intf ) {
104 104
 	return len;
105 105
 }
106 106
 
107
+/**
108
+ * Report change of flow control window
109
+ *
110
+ * @v intf		Data transfer interface
111
+ *
112
+ * Note that this method is used to indicate only unsolicited changes
113
+ * in the flow control window.  In particular, this method must not be
114
+ * called as part of the response to xfer_deliver(), since that could
115
+ * easily lead to an infinite loop.  Callers of xfer_deliver() should
116
+ * assume that the flow control window will have changed without
117
+ * generating an xfer_window_changed() message.
118
+ */
119
+void xfer_window_changed ( struct interface *intf ) {
120
+	struct interface *dest;
121
+	xfer_window_changed_TYPE ( void * ) *op =
122
+		intf_get_dest_op ( intf, xfer_window_changed, &dest );
123
+	void *object = intf_object ( dest );
124
+
125
+	if ( op ) {
126
+		op ( object );
127
+	} else {
128
+		/* Default is to do nothing */
129
+	}
130
+
131
+	intf_put ( dest );
132
+}
133
+
107 134
 /**
108 135
  * Allocate I/O buffer
109 136
  *

+ 4
- 0
src/include/ipxe/xfer.h View File

@@ -57,6 +57,10 @@ extern size_t xfer_window ( struct interface *intf );
57 57
 #define xfer_window_TYPE( object_type ) \
58 58
 	typeof ( size_t ( object_type ) )
59 59
 
60
+extern void xfer_window_changed ( struct interface *intf );
61
+#define xfer_window_changed_TYPE( object_type ) \
62
+	typeof ( void ( object_type ) )
63
+
60 64
 extern struct io_buffer * xfer_alloc_iob ( struct interface *intf,
61 65
 					   size_t len );
62 66
 #define xfer_alloc_iob_TYPE( object_type ) \

Loading…
Cancel
Save