caif: Don't resend if dev_queue_xmit fails.
authorSjur Brændeland <sjur.brandeland@stericsson.com>
Mon, 11 Apr 2011 10:43:51 +0000 (10:43 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 11 Apr 2011 22:08:48 +0000 (15:08 -0700)
If CAIF Link Layer returns an error, we no longer try to re-build the
CAIF packet and resend it. Instead, we simply return any transmission
errors to the socket client.

Signed-off-by: Sjur Brændeland <sjur.brandeland@stericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/caif/caif_dev.c
net/caif/caif_socket.c
net/caif/cfdgml.c
net/caif/cffrml.c
net/caif/cfmuxl.c
net/caif/cfserl.c
net/caif/cfutill.c
net/caif/cfveil.c
net/caif/cfvidl.c

index b533bb09a002f8cc3ea93cc6228bee0e5db5ea7c..a518fdd4da0ab5a297d07f33099e702a088a06c1 100644 (file)
@@ -120,25 +120,12 @@ static int transmit(struct cflayer *layer, struct cfpkt *pkt)
 {
        struct caif_device_entry *caifd =
            container_of(layer, struct caif_device_entry, layer);
-       struct sk_buff *skb, *skb2;
-       int ret = -EINVAL;
+       struct sk_buff *skb;
+
        skb = cfpkt_tonative(pkt);
        skb->dev = caifd->netdev;
-       /*
-        * Don't allow SKB to be destroyed upon error, but signal resend
-        * notification to clients. We can't rely on the return value as
-        * congestion (NET_XMIT_CN) sometimes drops the packet, sometimes don't.
-        */
-       if (netif_queue_stopped(caifd->netdev))
-               return -EAGAIN;
-       skb2 = skb_get(skb);
-
-       ret = dev_queue_xmit(skb2);
-
-       if (!ret)
-               kfree_skb(skb);
-       else
-               return -EAGAIN;
+
+       dev_queue_xmit(skb);
 
        return 0;
 }
index 37a4034dfc29ddbc8a1185bd3daf42ab617e30d3..20212424e2e8a9cc1ba2e0058c2f440c88634723 100644 (file)
@@ -519,43 +519,14 @@ static int transmit_skb(struct sk_buff *skb, struct caifsock *cf_sk,
                        int noblock, long timeo)
 {
        struct cfpkt *pkt;
-       int ret, loopcnt = 0;
 
        pkt = cfpkt_fromnative(CAIF_DIR_OUT, skb);
        memset(cfpkt_info(pkt), 0, sizeof(struct caif_payload_info));
-       do {
-
-               ret = -ETIMEDOUT;
 
-               /* Slight paranoia, probably not needed. */
-               if (unlikely(loopcnt++ > 1000)) {
-                       pr_warn("transmit retries failed, error = %d\n", ret);
-                       break;
-               }
+       if (cf_sk->layer.dn == NULL)
+               return -EINVAL;
 
-               if (cf_sk->layer.dn != NULL)
-                       ret = cf_sk->layer.dn->transmit(cf_sk->layer.dn, pkt);
-               if (likely(ret >= 0))
-                       break;
-               /* if transmit return -EAGAIN, then retry */
-               if (noblock && ret == -EAGAIN)
-                       break;
-               timeo = caif_wait_for_flow_on(cf_sk, 0, timeo, &ret);
-               if (signal_pending(current)) {
-                       ret = sock_intr_errno(timeo);
-                       break;
-               }
-               if (ret)
-                       break;
-               if (cf_sk->sk.sk_state != CAIF_CONNECTED ||
-                       sock_flag(&cf_sk->sk, SOCK_DEAD) ||
-                       (cf_sk->sk.sk_shutdown & RCV_SHUTDOWN)) {
-                       ret = -EPIPE;
-                       cf_sk->sk.sk_err = EPIPE;
-                       break;
-               }
-       } while (ret == -EAGAIN);
-       return ret;
+       return cf_sk->layer.dn->transmit(cf_sk->layer.dn, pkt);
 }
 
 /* Copied from af_unix:unix_dgram_sendmsg, and adapted to CAIF */
index 054fdb5aeb88073d89293a424fcf7c6458f4bd51..0382dec84fdc31591cf8cfa19316a6aeafbe2b9c 100644 (file)
@@ -108,10 +108,5 @@ static int cfdgml_transmit(struct cflayer *layr, struct cfpkt *pkt)
         */
        info->hdr_len = 4;
        info->dev_info = &service->dev_info;
-       ret = layr->dn->transmit(layr->dn, pkt);
-       if (ret < 0) {
-               u32 tmp32;
-               cfpkt_extr_head(pkt, &tmp32, 4);
-       }
-       return ret;
+       return layr->dn->transmit(layr->dn, pkt);
 }
index a445043931ae3f97af3df8a8c2b470ef7cea1321..2423fed8e26cec3dfc4c6d3cb5ab8c2c521b6b71 100644 (file)
@@ -120,7 +120,6 @@ static int cffrml_transmit(struct cflayer *layr, struct cfpkt *pkt)
        int tmp;
        u16 chks;
        u16 len;
-       int ret;
        struct cffrml *this = container_obj(layr);
        if (this->dofcs) {
                chks = cfpkt_iterate(pkt, cffrml_checksum, 0xffff);
@@ -137,12 +136,7 @@ static int cffrml_transmit(struct cflayer *layr, struct cfpkt *pkt)
                pr_err("Packet is erroneous!\n");
                return -EPROTO;
        }
-       ret = layr->dn->transmit(layr->dn, pkt);
-       if (ret < 0) {
-               /* Remove header on faulty packet. */
-               cfpkt_extr_head(pkt, &tmp, 2);
-       }
-       return ret;
+       return layr->dn->transmit(layr->dn, pkt);
 }
 
 static void cffrml_ctrlcmd(struct cflayer *layr, enum caif_ctrlcmd ctrl,
index f8ce0f3d9210d4a5f0688b706ed9991d11dc59fd..ebfda2c9290ba1a4e38c13b4ffd59f302cc50dba 100644 (file)
@@ -184,7 +184,6 @@ static int cfmuxl_receive(struct cflayer *layr, struct cfpkt *pkt)
 
 static int cfmuxl_transmit(struct cflayer *layr, struct cfpkt *pkt)
 {
-       int ret;
        struct cfmuxl *muxl = container_obj(layr);
        u8 linkid;
        struct cflayer *dn;
@@ -198,11 +197,7 @@ static int cfmuxl_transmit(struct cflayer *layr, struct cfpkt *pkt)
        info->hdr_len += 1;
        linkid = info->channel_id;
        cfpkt_add_head(pkt, &linkid, 1);
-       ret = dn->transmit(dn, pkt);
-       /* Remove MUX protocol header upon error. */
-       if (ret < 0)
-               cfpkt_extr_head(pkt, &linkid, 1);
-       return ret;
+       return dn->transmit(dn, pkt);
 }
 
 static void cfmuxl_ctrlcmd(struct cflayer *layr, enum caif_ctrlcmd ctrl,
index 8303fe3ebf891e820439c8359518022fe8c29a54..2715c84cfa871f58fdd7c4bfbfb87302806f2a19 100644 (file)
@@ -179,15 +179,10 @@ static int cfserl_receive(struct cflayer *l, struct cfpkt *newpkt)
 static int cfserl_transmit(struct cflayer *layer, struct cfpkt *newpkt)
 {
        struct cfserl *layr = container_obj(layer);
-       int ret;
        u8 tmp8 = CFSERL_STX;
        if (layr->usestx)
                cfpkt_add_head(newpkt, &tmp8, 1);
-       ret = layer->dn->transmit(layer->dn, newpkt);
-       if (ret < 0)
-               cfpkt_extr_head(newpkt, &tmp8, 1);
-
-       return ret;
+       return layer->dn->transmit(layer->dn, newpkt);
 }
 
 static void cfserl_ctrlcmd(struct cflayer *layr, enum caif_ctrlcmd ctrl,
index 315c0d60136887ed6e1001a73618839f91931afd..98e027db18ed0d3b768b669e900bd21cbbe074fb 100644 (file)
@@ -100,10 +100,5 @@ static int cfutill_transmit(struct cflayer *layr, struct cfpkt *pkt)
         */
        info->hdr_len = 1;
        info->dev_info = &service->dev_info;
-       ret = layr->dn->transmit(layr->dn, pkt);
-       if (ret < 0) {
-               u32 tmp32;
-               cfpkt_extr_head(pkt, &tmp32, 4);
-       }
-       return ret;
+       return layr->dn->transmit(layr->dn, pkt);
 }
index c3b1dec4acf648777409bbac36ea9b659e84f03a..1a588cd818ea95f4b5062d73d038788ecbe88354 100644 (file)
@@ -96,8 +96,5 @@ static int cfvei_transmit(struct cflayer *layr, struct cfpkt *pkt)
        info->channel_id = service->layer.id;
        info->hdr_len = 1;
        info->dev_info = &service->dev_info;
-       ret = layr->dn->transmit(layr->dn, pkt);
-       if (ret < 0)
-               cfpkt_extr_head(pkt, &tmp, 1);
-       return ret;
+       return layr->dn->transmit(layr->dn, pkt);
 }
index bf6fef2a0eff19ddacfc0ef980a625886404469f..b2f5989ad4554798208a2b2f61567e38d696d0fb 100644 (file)
@@ -60,8 +60,5 @@ static int cfvidl_transmit(struct cflayer *layr, struct cfpkt *pkt)
        info = cfpkt_info(pkt);
        info->channel_id = service->layer.id;
        info->dev_info = &service->dev_info;
-       ret = layr->dn->transmit(layr->dn, pkt);
-       if (ret < 0)
-               cfpkt_extr_head(pkt, &videoheader, 4);
-       return ret;
+       return layr->dn->transmit(layr->dn, pkt);
 }