]> rtime.felk.cvut.cz Git - linux-lin.git/commitdiff
sllin: Select enhanced checksum mode according to the cache and SFF frame even for...
authorPavel Pisa <pisa@cmp.felk.cvut.cz>
Tue, 10 Jan 2017 09:00:09 +0000 (10:00 +0100)
committerPavel Pisa <pisa@cmp.felk.cvut.cz>
Tue, 10 Jan 2017 09:00:09 +0000 (10:00 +0100)
Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
sllin/sllin.c

index 2db896fd8e812da8bd1f535862e3ae98e76d4f1a..3437631c465b83a7569ad9cb1dddd6ab164d8c94 100644 (file)
@@ -1013,6 +1013,7 @@ static int sllin_kwthread(void *ptr)
        struct sched_param schparam = { .sched_priority = 40 };
        int tx_bytes = 0; /* Used for Network statistics */
        unsigned long flags;
        struct sched_param schparam = { .sched_priority = 40 };
        int tx_bytes = 0; /* Used for Network statistics */
        unsigned long flags;
+       int mode;
        int lin_id;
        struct sllin_conf_entry *sce;
 
        int lin_id;
        struct sllin_conf_entry *sce;
 
@@ -1083,8 +1084,12 @@ static int sllin_kwthread(void *ptr)
                        if (!test_bit(SLF_MSGEVENT, &sl->flags))
                                break;
 
                        if (!test_bit(SLF_MSGEVENT, &sl->flags))
                                break;
 
+                       mode = 0;
                        cf = (struct can_frame *)sl->tx_req_skb->data;
 
                        cf = (struct can_frame *)sl->tx_req_skb->data;
 
+                       if (cf->can_id & LIN_CHECKSUM_EXTENDED)
+                               mode |= SLLIN_STPMSG_CHCKSUM_ENH;
+
                        /* SFF RTR CAN frame -> LIN header */
                        if (cf->can_id & CAN_RTR_FLAG) {
                                struct sllin_conf_entry *sce;
                        /* SFF RTR CAN frame -> LIN header */
                        if (cf->can_id & CAN_RTR_FLAG) {
                                struct sllin_conf_entry *sce;
@@ -1094,6 +1099,8 @@ static int sllin_kwthread(void *ptr)
 
                                sce = &sl->linfr_cache[cf->can_id & LIN_ID_MASK];
                                spin_lock_irqsave(&sl->linfr_lock, flags);
 
                                sce = &sl->linfr_cache[cf->can_id & LIN_ID_MASK];
                                spin_lock_irqsave(&sl->linfr_lock, flags);
+                               if (sce->frame_fl & LIN_CHECKSUM_EXTENDED)
+                                       mode |= SLLIN_STPMSG_CHCKSUM_ENH;
 
                                /* Is there Slave response in linfr_cache to be sent? */
                                if ((sce->frame_fl & LIN_CACHE_RESPONSE)
 
                                /* Is there Slave response in linfr_cache to be sent? */
                                if ((sce->frame_fl & LIN_CACHE_RESPONSE)
@@ -1114,9 +1121,15 @@ static int sllin_kwthread(void *ptr)
                                spin_unlock_irqrestore(&sl->linfr_lock, flags);
 
                        } else { /* SFF NON-RTR CAN frame -> LIN header + LIN response */
                                spin_unlock_irqrestore(&sl->linfr_lock, flags);
 
                        } else { /* SFF NON-RTR CAN frame -> LIN header + LIN response */
+                               struct sllin_conf_entry *sce;
+
                                netdev_dbg(sl->dev, "%s: NON-RTR SFF CAN frame, ID = %x\n",
                                        __func__, (int)cf->can_id & LIN_ID_MASK);
 
                                netdev_dbg(sl->dev, "%s: NON-RTR SFF CAN frame, ID = %x\n",
                                        __func__, (int)cf->can_id & LIN_ID_MASK);
 
+                               sce = &sl->linfr_cache[cf->can_id & LIN_ID_MASK];
+                               if (sce->frame_fl & LIN_CHECKSUM_EXTENDED)
+                                       mode |= SLLIN_STPMSG_CHCKSUM_ENH;
+
                                lin_data = cf->data;
                                lin_dlc = cf->can_dlc;
                                if (lin_dlc > SLLIN_DATA_MAX)
                                lin_data = cf->data;
                                lin_dlc = cf->can_dlc;
                                if (lin_dlc > SLLIN_DATA_MAX)
@@ -1124,7 +1137,7 @@ static int sllin_kwthread(void *ptr)
                                tx_bytes = lin_dlc;
                        }
 
                                tx_bytes = lin_dlc;
                        }
 
-                       if (sllin_setup_msg(sl, 0, cf->can_id & LIN_ID_MASK,
+                       if (sllin_setup_msg(sl, mode, cf->can_id & LIN_ID_MASK,
                                lin_data, lin_dlc) != -1) {
 
                                sl->id_to_send = true;
                                lin_data, lin_dlc) != -1) {
 
                                sl->id_to_send = true;
@@ -1242,7 +1255,6 @@ slstate_response_wait:
 
                        if ((sce->frame_fl & LIN_CACHE_RESPONSE)
                                        && (sce->dlc > 0)) {
 
                        if ((sce->frame_fl & LIN_CACHE_RESPONSE)
                                        && (sce->dlc > 0)) {
-                               int mode;
 
                                netdev_dbg(sl->dev, "Sending LIN response from linfr_cache\n");
 
 
                                netdev_dbg(sl->dev, "Sending LIN response from linfr_cache\n");