~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/net/caif/cfutill.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /net/caif/cfutill.c (Version linux-6.12-rc7) and /net/caif/cfutill.c (Version linux-5.14.21)


  1 // SPDX-License-Identifier: GPL-2.0-only            1 // SPDX-License-Identifier: GPL-2.0-only
  2 /*                                                  2 /*
  3  * Copyright (C) ST-Ericsson AB 2010                3  * Copyright (C) ST-Ericsson AB 2010
  4  * Author:      Sjur Brendeland                     4  * Author:      Sjur Brendeland
  5  */                                                 5  */
  6                                                     6 
  7 #define pr_fmt(fmt) KBUILD_MODNAME ":%s(): " f      7 #define pr_fmt(fmt) KBUILD_MODNAME ":%s(): " fmt, __func__
  8                                                     8 
  9 #include <linux/kernel.h>                           9 #include <linux/kernel.h>
 10 #include <linux/types.h>                           10 #include <linux/types.h>
 11 #include <linux/slab.h>                            11 #include <linux/slab.h>
 12 #include <linux/errno.h>                           12 #include <linux/errno.h>
 13 #include <net/caif/caif_layer.h>                   13 #include <net/caif/caif_layer.h>
 14 #include <net/caif/cfsrvl.h>                       14 #include <net/caif/cfsrvl.h>
 15 #include <net/caif/cfpkt.h>                        15 #include <net/caif/cfpkt.h>
 16                                                    16 
 17 #define container_obj(layr) ((struct cfsrvl *)     17 #define container_obj(layr) ((struct cfsrvl *) layr)
 18 #define UTIL_PAYLOAD  0x00                         18 #define UTIL_PAYLOAD  0x00
 19 #define UTIL_CMD_BIT  0x80                         19 #define UTIL_CMD_BIT  0x80
 20 #define UTIL_REMOTE_SHUTDOWN 0x82                  20 #define UTIL_REMOTE_SHUTDOWN 0x82
 21 #define UTIL_FLOW_OFF 0x81                         21 #define UTIL_FLOW_OFF 0x81
 22 #define UTIL_FLOW_ON  0x80                         22 #define UTIL_FLOW_ON  0x80
 23                                                    23 
 24 static int cfutill_receive(struct cflayer *lay     24 static int cfutill_receive(struct cflayer *layr, struct cfpkt *pkt);
 25 static int cfutill_transmit(struct cflayer *la     25 static int cfutill_transmit(struct cflayer *layr, struct cfpkt *pkt);
 26                                                    26 
 27 struct cflayer *cfutill_create(u8 channel_id,      27 struct cflayer *cfutill_create(u8 channel_id, struct dev_info *dev_info)
 28 {                                                  28 {
 29         struct cfsrvl *util = kzalloc(sizeof(s     29         struct cfsrvl *util = kzalloc(sizeof(struct cfsrvl), GFP_ATOMIC);
 30         if (!util)                                 30         if (!util)
 31                 return NULL;                       31                 return NULL;
 32         caif_assert(offsetof(struct cfsrvl, la     32         caif_assert(offsetof(struct cfsrvl, layer) == 0);
 33         cfsrvl_init(util, channel_id, dev_info     33         cfsrvl_init(util, channel_id, dev_info, true);
 34         util->layer.receive = cfutill_receive;     34         util->layer.receive = cfutill_receive;
 35         util->layer.transmit = cfutill_transmi     35         util->layer.transmit = cfutill_transmit;
 36         snprintf(util->layer.name, CAIF_LAYER_     36         snprintf(util->layer.name, CAIF_LAYER_NAME_SZ, "util1");
 37         return &util->layer;                       37         return &util->layer;
 38 }                                                  38 }
 39                                                    39 
 40 static int cfutill_receive(struct cflayer *lay     40 static int cfutill_receive(struct cflayer *layr, struct cfpkt *pkt)
 41 {                                                  41 {
 42         u8 cmd = -1;                               42         u8 cmd = -1;
 43         struct cfsrvl *service = container_obj     43         struct cfsrvl *service = container_obj(layr);
 44         caif_assert(layr != NULL);                 44         caif_assert(layr != NULL);
 45         caif_assert(layr->up != NULL);             45         caif_assert(layr->up != NULL);
 46         caif_assert(layr->up->receive != NULL)     46         caif_assert(layr->up->receive != NULL);
 47         caif_assert(layr->up->ctrlcmd != NULL)     47         caif_assert(layr->up->ctrlcmd != NULL);
 48         if (cfpkt_extr_head(pkt, &cmd, 1) < 0)     48         if (cfpkt_extr_head(pkt, &cmd, 1) < 0) {
 49                 pr_err("Packet is erroneous!\n     49                 pr_err("Packet is erroneous!\n");
 50                 cfpkt_destroy(pkt);                50                 cfpkt_destroy(pkt);
 51                 return -EPROTO;                    51                 return -EPROTO;
 52         }                                          52         }
 53                                                    53 
 54         switch (cmd) {                             54         switch (cmd) {
 55         case UTIL_PAYLOAD:                         55         case UTIL_PAYLOAD:
 56                 return layr->up->receive(layr-     56                 return layr->up->receive(layr->up, pkt);
 57         case UTIL_FLOW_OFF:                        57         case UTIL_FLOW_OFF:
 58                 layr->ctrlcmd(layr, CAIF_CTRLC     58                 layr->ctrlcmd(layr, CAIF_CTRLCMD_FLOW_OFF_IND, 0);
 59                 cfpkt_destroy(pkt);                59                 cfpkt_destroy(pkt);
 60                 return 0;                          60                 return 0;
 61         case UTIL_FLOW_ON:                         61         case UTIL_FLOW_ON:
 62                 layr->ctrlcmd(layr, CAIF_CTRLC     62                 layr->ctrlcmd(layr, CAIF_CTRLCMD_FLOW_ON_IND, 0);
 63                 cfpkt_destroy(pkt);                63                 cfpkt_destroy(pkt);
 64                 return 0;                          64                 return 0;
 65         case UTIL_REMOTE_SHUTDOWN:      /* Rem     65         case UTIL_REMOTE_SHUTDOWN:      /* Remote Shutdown Request */
 66                 pr_err("REMOTE SHUTDOWN REQUES     66                 pr_err("REMOTE SHUTDOWN REQUEST RECEIVED\n");
 67                 layr->ctrlcmd(layr, CAIF_CTRLC     67                 layr->ctrlcmd(layr, CAIF_CTRLCMD_REMOTE_SHUTDOWN_IND, 0);
 68                 service->open = false;             68                 service->open = false;
 69                 cfpkt_destroy(pkt);                69                 cfpkt_destroy(pkt);
 70                 return 0;                          70                 return 0;
 71         default:                                   71         default:
 72                 cfpkt_destroy(pkt);                72                 cfpkt_destroy(pkt);
 73                 pr_warn("Unknown service contr     73                 pr_warn("Unknown service control %d (0x%x)\n", cmd, cmd);
 74                 return -EPROTO;                    74                 return -EPROTO;
 75         }                                          75         }
 76 }                                                  76 }
 77                                                    77 
 78 static int cfutill_transmit(struct cflayer *la     78 static int cfutill_transmit(struct cflayer *layr, struct cfpkt *pkt)
 79 {                                                  79 {
 80         u8 zero = 0;                               80         u8 zero = 0;
 81         struct caif_payload_info *info;            81         struct caif_payload_info *info;
 82         int ret;                                   82         int ret;
 83         struct cfsrvl *service = container_obj     83         struct cfsrvl *service = container_obj(layr);
 84         caif_assert(layr != NULL);                 84         caif_assert(layr != NULL);
 85         caif_assert(layr->dn != NULL);             85         caif_assert(layr->dn != NULL);
 86         caif_assert(layr->dn->transmit != NULL     86         caif_assert(layr->dn->transmit != NULL);
 87                                                    87 
 88         if (!cfsrvl_ready(service, &ret)) {        88         if (!cfsrvl_ready(service, &ret)) {
 89                 cfpkt_destroy(pkt);                89                 cfpkt_destroy(pkt);
 90                 return ret;                        90                 return ret;
 91         }                                          91         }
 92                                                    92 
 93         cfpkt_add_head(pkt, &zero, 1);             93         cfpkt_add_head(pkt, &zero, 1);
 94         /* Add info for MUX-layer to route the     94         /* Add info for MUX-layer to route the packet out. */
 95         info = cfpkt_info(pkt);                    95         info = cfpkt_info(pkt);
 96         info->channel_id = service->layer.id;      96         info->channel_id = service->layer.id;
 97         /*                                         97         /*
 98          * To optimize alignment, we add up th     98          * To optimize alignment, we add up the size of CAIF header before
 99          * payload.                                99          * payload.
100          */                                       100          */
101         info->hdr_len = 1;                        101         info->hdr_len = 1;
102         info->dev_info = &service->dev_info;      102         info->dev_info = &service->dev_info;
103         return layr->dn->transmit(layr->dn, pk    103         return layr->dn->transmit(layr->dn, pkt);
104 }                                                 104 }
105                                                   105 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php