linux/net/caif/cfserl.c
<<
>>
Prefs
   1/*
   2 * Copyright (C) ST-Ericsson AB 2010
   3 * Author:      Sjur Brendeland/sjur.brandeland@stericsson.com
   4 * License terms: GNU General Public License (GPL) version 2
   5 */
   6
   7#define pr_fmt(fmt) KBUILD_MODNAME ":%s(): " fmt, __func__
   8
   9#include <linux/stddef.h>
  10#include <linux/spinlock.h>
  11#include <linux/slab.h>
  12#include <net/caif/caif_layer.h>
  13#include <net/caif/cfpkt.h>
  14#include <net/caif/cfserl.h>
  15
  16#define container_obj(layr) ((struct cfserl *) layr)
  17
  18#define CFSERL_STX 0x02
  19#define SERIAL_MINIUM_PACKET_SIZE 4
  20#define SERIAL_MAX_FRAMESIZE 4096
  21struct cfserl {
  22        struct cflayer layer;
  23        struct cfpkt *incomplete_frm;
  24        /* Protects parallel processing of incoming packets */
  25        spinlock_t sync;
  26        bool usestx;
  27};
  28
  29static int cfserl_receive(struct cflayer *layr, struct cfpkt *pkt);
  30static int cfserl_transmit(struct cflayer *layr, struct cfpkt *pkt);
  31static void cfserl_ctrlcmd(struct cflayer *layr, enum caif_ctrlcmd ctrl,
  32                                int phyid);
  33
  34struct cflayer *cfserl_create(int instance, bool use_stx)
  35{
  36        struct cfserl *this = kzalloc(sizeof(struct cfserl), GFP_ATOMIC);
  37        if (!this)
  38                return NULL;
  39        caif_assert(offsetof(struct cfserl, layer) == 0);
  40        this->layer.receive = cfserl_receive;
  41        this->layer.transmit = cfserl_transmit;
  42        this->layer.ctrlcmd = cfserl_ctrlcmd;
  43        this->usestx = use_stx;
  44        spin_lock_init(&this->sync);
  45        snprintf(this->layer. =  [_LAYER_">&q_SZ> 0x02
&q_SZef="+co#37;s(): " 4 36        struct <4 href4"+code=cfserlclass="ass="sref">this->sync)>;
4 37        if (!4 38                4eturn4rl.c#L29" id="L29" class="line" na4e="L39">4 39        cfserl_receive(struct cflayer *layr,  href="net/caif/cfpkt" class="sref">cfpkt *pkt);
new*5 40        5 41        cfserl *this  enum ontainer_obj(layr)  href="net/caif/cfpkc#L45" id="L45" class="line" na5e="L42">5 42        this-u  16#denet/cai=conta="sref">phyidkt_ljax_ef="net/caif/cfs_ljarl.c#L23" id="L23" class="line" na5e="L43">5 43        cfpkt *5 44        cfpkt *    5snpriu816#denet/cai8onta="sref">phyid#denet/catmp8rl.c#L39" id="L39" class="line" na5e="L36">5 36        struct <5 href5bool" class="sref">bool u  16#denet/cai=conta="sref">phyid#denet/catmprl.c#L39" id="L39" class="line" na5e="L37">5 37        if (!snpriu816#denet/cai8onta="sref">phyid;
use_stERL_STX 0x02
5 38                5eturn55 39        cau  16#denet/cai=conta="sref">phyid6 40        6 41        this-if_assert(offsenew*6 42        this-ref="+codt(&this- enum sync);
6 43        6 44        this- enum sync)>incomplete_frm;
  6 5this- enum sync)>incomplete_frm;
    6
this-iompl_appenmd;
layr) enum sync)>incomplete_frm;
6 37        if (!this-sync)>incomplete_frm;
6 38                6eturn6this-6 39        this-ref="un+codt(&this- enum sync);
7 40        sync)ENOMEM href="net/caifENOMEMrl.c#L45" id="L45" class="line" na7e="L41">7 41        7 42        7 43        this-7 44          7 5snpri enum sync)>incomplete_frm;
  7 6
    7#define 7 38                7eturn7
<*7 39        this- enum sync)/a> = 8 40        this-iompl_extr_div>d;
layr)this-&mp816#denet/catmp8rl.c, 1c#L45" id="L45" class="line" na8e="L41">8 41        this-&mp816#denet/catmp8rl.c !cmd" class="sref"ERL_STX 0x02
8 42        this-"nmpl_morve(struct layr)8 43        phyid#denet/catmp8rl.c !cmd" class="sref"ERL_STX 0x02
8 44        this-iompl_extr_div>d;
layr)this-&mp816#denet/catmp8rl.c, 1c#L45" id="L45" class="line" na8="L5">  8 5  8 6
this)"nmpl_morve(struct layr)  8 7#define this-iompl_de_sroye(struct layr)    8
this- enum sync)>incomplete_frm;
8 39        this-ref="un+codt(&this- enum sync);
9 40        sync)EPROTO href="net/caifEPROTOrl.c#L39" id="L39" class="line" na9e="L41">9 41        9 42        9 43        9 44          9 5this->kt_ljax_ef="net/caif/cfs_ljarl.clcmd" class="sref">ccfs_getljax_ef="net/caif/>ccfs_getljaass="sref">layr)  9 6
  9 7#define   9 8

    9#include <
   10#include <
 0 11#include <
 0 12#include < 0 13#include <this- 0 14#include <this- enum sync)/a> =  0 15
this-iompl_add_div>d;
layr)this->;
 0 16#define this- enum sync)>incomplete_frm;
 0 17
this-ref="un+codt(&this- enum sync);
 0 18#define  0 19#define    10#include <   11#include <   12#include <
   13#include <   14#include <   15
this-"nmpl_peek_div>d;
layr)this-&mp16#denet/catmperl.,"2c#L45" id="L45" class="line" na1me="L16">   16#define layr)&mp16#denet/catmperl.) + 2#L45" id="L45" class="line" na1me="L17">   17
   18#define 
   19#define 
1  20#define this-expectljax_ef="net/caif/expectljax" clf/cf sref">this-lass="sref">SERIAL_MINIUM_PACKET_SIZE 4
   21struct SERIAL_MAX_FRAMESIZE 4096
1  22        struct <1a hre12         int this) enum sync)/a> = 1  23        struct <1a hre123nprintf" cla class="""""""""""""""""ass=sref">this-   24        this-iompl_de_sroye(struct layr)1  25        this- enum sync)>incomplete_frm;
1  26        1  27};
this-ref="un+codt(&this- enum sync);
1  28
sync)EPROTO href="net/caifEPROTOrl.c#L39" id="L39" class="line" na1me="L29">1  29static int 1  30static int    31static void 1  32                1     132l.c#L7" id="L7" class="line" name1me="L33">1  33
this-1  34struct 1  35{
this- enum sync)/a> = 1  36        struct <1a hre136nprintf" cla class="ss="""""""""""""ode=use_stx" cliompl_add_div>d;
layr)this->;
1  37        if (!this- enum sync)>incomplete_frm;
1  38                1retur1 this-ref="un+codt(&this- enum sync);
1  39        1  40        1  41        1  42        
1  43        1  44        1  45        
14 36        struct <14 hre146nprintf" cla class="ass=sref">this-14 37        if (!this-e=ll_*;
layr)14 38                14etur1414 39        this-e=ll_*15 40        15 41        
<*t/cai upwards.*fserl.c#L25" id="L25" class="line" na15e="L42">15 42        this-ref="un+codt(&this- enum sync);
15 43        this-rea href="+code=inreacfselcmd" class="sref" enum sync)>.#denet/caupif_cass="sref">sync)e = this- enum sync)>.#denet/caupif_c,"AMESIZE" class=15 44        this-ref="+codt(&this- enum sync);
  1  5this-rea href="+code=inreacfselc="-sref">sync)EILSEQ href="net/caifEILSEQx" ccc#L22" id="L22" class="line" na15e="L36">15 36        struct <15 hre156nprintf" cla class="ss="""""ass=sref">this- enum sync)/a> = 15 37        if (!this-&=ll_*15 38                15etur15this-;
layr)15 39        
16 40        16 41        16 42        this-iompl_de_sroye(struct layr)16 43        this-16 44          16 5   16#define 16 37        if (!this-16 38                16etur16rl.c#L29" id="L29" class="line" na16e="L39">16 39        this-17 40        17 41        this-ref="un+codt(&this- enum sync);
17 42        17 43        17 44          17 5cfserl_transmit(struct cflayer *layr, sta href="+code=s" ccaif/cfst" class="sref">cfpkt *pkt);
new*  17 6
   17
cfserl *this  enum ontainer_obj(layr) ) == 0);
17 38                17etur17sync)/816#denet/cai8onta="sref">phyid#denet/catmp8rl.class="sref">use_stERL_STX 0x02
17 39        this- enum sync)/a> = 18 40        d;
layr)new*this-&mp816#denet/catmp8rl.c, 1c#L45" id="L45" class="line" na18e="L41">18 41        NULL; ) == 0);
sync)dax_ef="net/caif/dnif/cass="sref">sync)mit = layr) ) == 0);
sync)dax_ef="net/caif/dnif/c+code=use_stx" clnew*18 42        18 43        18 44        cfserl_ctrlcmd(struct cflayer *layr, enum caif_ctrlcmd ctrl,
  18 5phyid);
  18 6
  18 7#define snpri enum sync)/p16#denet/caupif_cass="sref">sync)d = this- enum sync)/p16#denet/caupif_c,"AMESIZE" class=
phyid);
   18#define 18 39        


foot *<> The original LXR software by the 23" id="Lhttp://sourceforge.23" projinco/lx*<>LXR net/unityrl.c#=sync experi/caial version by 23" id="Lm=llto:lx*@l"net.noodex*@l"net.no/cfse
subfoot *<> ex*.l"net.no kindly hosted/by 23" id="Lhttp://www.redpill-l"npro.noodRedpill L"npro ASrl.c#=providern>