Implemented poll(); receiving on generic device also works.
authorFlorian Pose <fp@igh-essen.com>
Thu, 15 Oct 2009 18:01:41 +0200
changeset 1542 91ae9c95dd2e
parent 1541 26ac1c611100
child 1544 cfcaf46c5b3f
Implemented poll(); receiving on generic device also works.
devices/generic.c
--- a/devices/generic.c	Thu Oct 15 17:38:53 2009 +0200
+++ b/devices/generic.c	Thu Oct 15 18:01:41 2009 +0200
@@ -75,6 +75,7 @@
 int ec_gen_device_open(ec_gen_device_t *);
 int ec_gen_device_stop(ec_gen_device_t *);
 int ec_gen_device_start_xmit(ec_gen_device_t *, struct sk_buff *);
+void ec_gen_device_poll(ec_gen_device_t *);
 
 /*****************************************************************************/
 
@@ -107,6 +108,8 @@
 
 void ec_gen_poll(struct net_device *dev)
 {
+    ec_gen_device_t *gendev = *((ec_gen_device_t **) netdev_priv(dev));
+    ec_gen_device_poll(gendev);
 }
 
 /*****************************************************************************/
@@ -271,6 +274,35 @@
 
 /*****************************************************************************/
 
+/** Polls the device.
+ */
+void ec_gen_device_poll(
+        ec_gen_device_t *dev
+        )
+{
+    struct msghdr msg;
+    struct kvec iov;
+    char buf[2000]; // FIXME
+    int ret, budget = 10; // FIXME
+
+    iov.iov_base = buf;
+    iov.iov_len = 2000;
+    memset(&msg, 0, sizeof(msg));
+
+    do {
+        ret = kernel_recvmsg(dev->socket, &msg, &iov, 1, iov.iov_len,
+                MSG_DONTWAIT);
+        if (ret > 0) {
+            ecdev_receive(dev->ecdev, buf, ret);
+        } else if (ret < 0) {
+            break;
+        }
+        budget--;
+    } while (budget);
+}
+
+/*****************************************************************************/
+
 /** Offer device.
  */
 int offer_device(