Implement TSO
[akaros.git] / kern / src / net / pktmedium.c
index 4613460..6143f87 100644 (file)
 #include <smp.h>
 #include <ip.h>
 
-static void    pktbind(struct Ipifc*i, int unused_int, char **unused_char_pp_t);
-static void    pktunbind(struct Ipifc* i);
-static void    pktbwrite(struct Ipifc*i, struct block*, int unused_int, uint8_t *unused_uint8_p_t);
-static void    pktin(struct Fs*f, struct Ipifc*i, struct block*b);
+static void pktbind(struct Ipifc *i, int unused_int, char **unused_char_pp_t);
+static void pktunbind(struct Ipifc *i);
+static void pktbwrite(struct Ipifc *i, struct block *, int unused_int,
+                                         uint8_t * unused_uint8_p_t);
+static void pktin(struct Fs *f, struct Ipifc *i, struct block *b);
 
-struct medium pktmedium =
-{
-.name=         "pkt",
-.hsize=                14,
-.mintu=                40,
-.maxtu=                4*1024,
-.maclen=       6,
-.bind=         pktbind,
-.unbind=       pktunbind,
-.bwrite=       pktbwrite,
-.pktin=                pktin,
-.unbindonclose=        1,
+struct medium pktmedium = {
+       .name = "pkt",
+       .hsize = 14,
+       .mintu = 40,
+       .maxtu = 4 * 1024,
+       .maclen = 6,
+       .bind = pktbind,
+       .unbind = pktunbind,
+       .bwrite = pktbwrite,
+       .pktin = pktin,
+       .unbindonclose = 1,
 };
 
 /*
  *  called to bind an IP ifc to an ethernet device
  *  called with ifc wlock'd
  */
-static void
-pktbind(struct Ipifc*i, int unused_int, char **unused_char_pp_t)
+static void pktbind(struct Ipifc *i, int unused_int, char **unused_char_pp_t)
 {
 }
 
 /*
  *  called with ifc wlock'd
  */
-static void
-pktunbind(struct Ipifc*i)
+static void pktunbind(struct Ipifc *i)
 {
 }
 
@@ -53,11 +51,13 @@ pktunbind(struct Ipifc*i)
  *  called by ipoput with a single packet to write
  */
 static void
-pktbwrite(struct Ipifc *ifc, struct block *bp, int unused_int, uint8_t *unused_uint8_p_t)
+pktbwrite(struct Ipifc *ifc, struct block *bp, int unused_int,
+                 uint8_t * unused_uint8_p_t)
 {
        /* enqueue onto the conversation's rq */
        bp = concatblock(bp);
-       if(kref_refcnt(&ifc->conv->snoopers) > 0)
+       ptclcsum_finalize(bp, 0);
+       if (atomic_read(&ifc->conv->snoopers) > 0)
                qpass(ifc->conv->sq, copyblock(bp, BLEN(bp)));
        qpass(ifc->conv->rq, bp);
 }
@@ -65,20 +65,18 @@ pktbwrite(struct Ipifc *ifc, struct block *bp, int unused_int, uint8_t *unused_u
 /*
  *  called with ifc rlocked when someone write's to 'data'
  */
-static void
-pktin(struct Fs *f, struct Ipifc *ifc, struct block *bp)
+static void pktin(struct Fs *f, struct Ipifc *ifc, struct block *bp)
 {
-       if(ifc->lifc == NULL)
+       if (ifc->lifc == NULL)
                freeb(bp);
        else {
-               if(kref_refcnt(&ifc->conv->snoopers) > 0)
+               if (atomic_read(&ifc->conv->snoopers) > 0)
                        qpass(ifc->conv->sq, copyblock(bp, BLEN(bp)));
                ipiput4(f, ifc, bp);
        }
 }
 
-void
-pktmediumlink(void)
+void pktmediumlink(void)
 {
        addipmedium(&pktmedium);
 }