2005-04-17 06:20:36 +08:00
|
|
|
/* $Id: hycapi.c,v 1.8.6.4 2001/09/23 22:24:54 kai Exp $
|
|
|
|
*
|
|
|
|
* Linux driver for HYSDN cards, CAPI2.0-Interface.
|
|
|
|
*
|
|
|
|
* Author Ulrich Albrecht <u.albrecht@hypercope.de> for Hypercope GmbH
|
|
|
|
* Copyright 2000 by Hypercope GmbH
|
|
|
|
*
|
|
|
|
* This software may be used and distributed according to the terms
|
|
|
|
* of the GNU General Public License, incorporated herein by reference.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
2010-01-14 19:10:54 +08:00
|
|
|
#include <linux/proc_fs.h>
|
|
|
|
#include <linux/seq_file.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/signal.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/skbuff.h>
|
|
|
|
#include <linux/netdevice.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#define VER_DRIVER 0
|
|
|
|
#define VER_CARDTYPE 1
|
|
|
|
#define VER_HWID 2
|
|
|
|
#define VER_SERIAL 3
|
|
|
|
#define VER_OPTION 4
|
|
|
|
#define VER_PROTO 5
|
|
|
|
#define VER_PROFILE 6
|
|
|
|
#define VER_CAPI 7
|
|
|
|
|
|
|
|
#include "hysdn_defs.h"
|
|
|
|
#include <linux/kernelcapi.h>
|
|
|
|
|
2012-02-20 11:52:38 +08:00
|
|
|
static char hycapi_revision[] = "$Revision: 1.8.6.4 $";
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2012-02-20 11:52:38 +08:00
|
|
|
unsigned int hycapi_enable = 0xffffffff;
|
2006-03-25 19:07:05 +08:00
|
|
|
module_param(hycapi_enable, uint, 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
typedef struct _hycapi_appl {
|
|
|
|
unsigned int ctrl_mask;
|
|
|
|
capi_register_params rp;
|
|
|
|
struct sk_buff *listen_req[CAPI_MAXCONTR];
|
|
|
|
} hycapi_appl;
|
|
|
|
|
|
|
|
static hycapi_appl hycapi_applications[CAPI_MAXAPPL];
|
|
|
|
|
2005-06-29 11:44:56 +08:00
|
|
|
static u16 hycapi_send_message(struct capi_ctr *ctrl, struct sk_buff *skb);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
static inline int _hycapi_appCheck(int app_id, int ctrl_no)
|
|
|
|
{
|
2012-02-20 11:52:38 +08:00
|
|
|
if ((ctrl_no <= 0) || (ctrl_no > CAPI_MAXCONTR) || (app_id <= 0) ||
|
2005-04-17 06:20:36 +08:00
|
|
|
(app_id > CAPI_MAXAPPL))
|
|
|
|
{
|
|
|
|
printk(KERN_ERR "HYCAPI: Invalid request app_id %d for controller %d", app_id, ctrl_no);
|
|
|
|
return -1;
|
|
|
|
}
|
2012-02-20 11:52:38 +08:00
|
|
|
return ((hycapi_applications[app_id - 1].ctrl_mask & (1 << (ctrl_no-1))) != 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************
|
|
|
|
Kernel-Capi callback reset_ctr
|
2012-02-20 11:52:38 +08:00
|
|
|
******************************/
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-06-29 11:44:56 +08:00
|
|
|
static void
|
2005-04-17 06:20:36 +08:00
|
|
|
hycapi_reset_ctr(struct capi_ctr *ctrl)
|
|
|
|
{
|
|
|
|
hycapictrl_info *cinfo = ctrl->driverdata;
|
|
|
|
|
|
|
|
#ifdef HYCAPI_PRINTFNAMES
|
|
|
|
printk(KERN_NOTICE "HYCAPI hycapi_reset_ctr\n");
|
|
|
|
#endif
|
|
|
|
capilib_release(&cinfo->ncci_head);
|
2009-06-07 17:09:23 +08:00
|
|
|
capi_ctr_down(ctrl);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************
|
|
|
|
Kernel-Capi callback remove_ctr
|
2012-02-20 11:52:38 +08:00
|
|
|
******************************/
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-06-29 11:44:56 +08:00
|
|
|
static void
|
2005-04-17 06:20:36 +08:00
|
|
|
hycapi_remove_ctr(struct capi_ctr *ctrl)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
hycapictrl_info *cinfo = NULL;
|
|
|
|
hysdn_card *card = NULL;
|
|
|
|
#ifdef HYCAPI_PRINTFNAMES
|
|
|
|
printk(KERN_NOTICE "HYCAPI hycapi_remove_ctr\n");
|
2012-02-20 11:52:38 +08:00
|
|
|
#endif
|
2005-04-17 06:20:36 +08:00
|
|
|
cinfo = (hycapictrl_info *)(ctrl->driverdata);
|
2012-02-20 11:52:38 +08:00
|
|
|
if (!cinfo) {
|
2005-04-17 06:20:36 +08:00
|
|
|
printk(KERN_ERR "No hycapictrl_info set!");
|
|
|
|
return;
|
2012-02-20 11:52:38 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
card = cinfo->card;
|
|
|
|
capi_ctr_suspend_output(ctrl);
|
2012-02-20 11:52:38 +08:00
|
|
|
for (i = 0; i < CAPI_MAXAPPL; i++) {
|
|
|
|
if (hycapi_applications[i].listen_req[ctrl->cnr - 1]) {
|
|
|
|
kfree_skb(hycapi_applications[i].listen_req[ctrl->cnr - 1]);
|
|
|
|
hycapi_applications[i].listen_req[ctrl->cnr - 1] = NULL;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
detach_capi_ctr(ctrl);
|
|
|
|
ctrl->driverdata = NULL;
|
|
|
|
kfree(card->hyctrlinfo);
|
|
|
|
|
2012-02-20 11:52:38 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
card->hyctrlinfo = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************
|
|
|
|
|
|
|
|
Queue a CAPI-message to the controller.
|
|
|
|
|
|
|
|
***********************************************************/
|
|
|
|
|
|
|
|
static void
|
|
|
|
hycapi_sendmsg_internal(struct capi_ctr *ctrl, struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
hycapictrl_info *cinfo = (hycapictrl_info *)(ctrl->driverdata);
|
|
|
|
hysdn_card *card = cinfo->card;
|
|
|
|
|
|
|
|
spin_lock_irq(&cinfo->lock);
|
|
|
|
#ifdef HYCAPI_PRINTFNAMES
|
2012-02-20 11:52:38 +08:00
|
|
|
printk(KERN_NOTICE "hycapi_send_message\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif
|
|
|
|
cinfo->skbs[cinfo->in_idx++] = skb; /* add to buffer list */
|
|
|
|
if (cinfo->in_idx >= HYSDN_MAX_CAPI_SKB)
|
|
|
|
cinfo->in_idx = 0; /* wrap around */
|
|
|
|
cinfo->sk_count++; /* adjust counter */
|
|
|
|
if (cinfo->sk_count >= HYSDN_MAX_CAPI_SKB) {
|
|
|
|
/* inform upper layers we're full */
|
|
|
|
printk(KERN_ERR "HYSDN Card%d: CAPI-buffer overrun!\n",
|
2012-02-20 11:52:38 +08:00
|
|
|
card->myid);
|
2005-04-17 06:20:36 +08:00
|
|
|
capi_ctr_suspend_output(ctrl);
|
|
|
|
}
|
|
|
|
cinfo->tx_skb = skb;
|
|
|
|
spin_unlock_irq(&cinfo->lock);
|
|
|
|
schedule_work(&card->irq_queue);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************
|
|
|
|
hycapi_register_internal
|
|
|
|
|
|
|
|
Send down the CAPI_REGISTER-Command to the controller.
|
|
|
|
This functions will also be used if the adapter has been rebooted to
|
|
|
|
re-register any applications in the private list.
|
|
|
|
|
|
|
|
************************************************************/
|
|
|
|
|
2012-02-20 11:52:38 +08:00
|
|
|
static void
|
2005-04-17 06:20:36 +08:00
|
|
|
hycapi_register_internal(struct capi_ctr *ctrl, __u16 appl,
|
|
|
|
capi_register_params *rp)
|
|
|
|
{
|
|
|
|
char ExtFeatureDefaults[] = "49 /0/0/0/0,*/1,*/2,*/3,*/4,*/5,*/6,*/7,*/8,*/9,*";
|
|
|
|
hycapictrl_info *cinfo = (hycapictrl_info *)(ctrl->driverdata);
|
|
|
|
hysdn_card *card = cinfo->card;
|
|
|
|
struct sk_buff *skb;
|
|
|
|
__u16 len;
|
|
|
|
__u8 _command = 0xa0, _subcommand = 0x80;
|
|
|
|
__u16 MessageNumber = 0x0000;
|
|
|
|
__u16 MessageBufferSize = 0;
|
|
|
|
int slen = strlen(ExtFeatureDefaults);
|
|
|
|
#ifdef HYCAPI_PRINTFNAMES
|
2012-02-20 11:52:38 +08:00
|
|
|
printk(KERN_NOTICE "hycapi_register_appl\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif
|
2012-02-20 11:52:38 +08:00
|
|
|
MessageBufferSize = rp->level3cnt * rp->datablkcnt * rp->datablklen;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
len = CAPI_MSG_BASELEN + 8 + slen + 1;
|
|
|
|
if (!(skb = alloc_skb(len, GFP_ATOMIC))) {
|
|
|
|
printk(KERN_ERR "HYSDN card%d: memory squeeze in hycapi_register_appl\n",
|
|
|
|
card->myid);
|
|
|
|
return;
|
|
|
|
}
|
networking: introduce and use skb_put_data()
A common pattern with skb_put() is to just want to memcpy()
some data into the new space, introduce skb_put_data() for
this.
An spatch similar to the one for skb_put_zero() converts many
of the places using it:
@@
identifier p, p2;
expression len, skb, data;
type t, t2;
@@
(
-p = skb_put(skb, len);
+p = skb_put_data(skb, data, len);
|
-p = (t)skb_put(skb, len);
+p = skb_put_data(skb, data, len);
)
(
p2 = (t2)p;
-memcpy(p2, data, len);
|
-memcpy(p, data, len);
)
@@
type t, t2;
identifier p, p2;
expression skb, data;
@@
t *p;
...
(
-p = skb_put(skb, sizeof(t));
+p = skb_put_data(skb, data, sizeof(t));
|
-p = (t *)skb_put(skb, sizeof(t));
+p = skb_put_data(skb, data, sizeof(t));
)
(
p2 = (t2)p;
-memcpy(p2, data, sizeof(*p));
|
-memcpy(p, data, sizeof(*p));
)
@@
expression skb, len, data;
@@
-memcpy(skb_put(skb, len), data, len);
+skb_put_data(skb, data, len);
(again, manually post-processed to retain some comments)
Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-06-16 20:29:20 +08:00
|
|
|
skb_put_data(skb, &len, sizeof(__u16));
|
|
|
|
skb_put_data(skb, &appl, sizeof(__u16));
|
2017-06-18 22:52:04 +08:00
|
|
|
skb_put_data(skb, &_command, sizeof(__u8));
|
|
|
|
skb_put_data(skb, &_subcommand, sizeof(__u8));
|
networking: introduce and use skb_put_data()
A common pattern with skb_put() is to just want to memcpy()
some data into the new space, introduce skb_put_data() for
this.
An spatch similar to the one for skb_put_zero() converts many
of the places using it:
@@
identifier p, p2;
expression len, skb, data;
type t, t2;
@@
(
-p = skb_put(skb, len);
+p = skb_put_data(skb, data, len);
|
-p = (t)skb_put(skb, len);
+p = skb_put_data(skb, data, len);
)
(
p2 = (t2)p;
-memcpy(p2, data, len);
|
-memcpy(p, data, len);
)
@@
type t, t2;
identifier p, p2;
expression skb, data;
@@
t *p;
...
(
-p = skb_put(skb, sizeof(t));
+p = skb_put_data(skb, data, sizeof(t));
|
-p = (t *)skb_put(skb, sizeof(t));
+p = skb_put_data(skb, data, sizeof(t));
)
(
p2 = (t2)p;
-memcpy(p2, data, sizeof(*p));
|
-memcpy(p, data, sizeof(*p));
)
@@
expression skb, len, data;
@@
-memcpy(skb_put(skb, len), data, len);
+skb_put_data(skb, data, len);
(again, manually post-processed to retain some comments)
Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-06-16 20:29:20 +08:00
|
|
|
skb_put_data(skb, &MessageNumber, sizeof(__u16));
|
|
|
|
skb_put_data(skb, &MessageBufferSize, sizeof(__u16));
|
|
|
|
skb_put_data(skb, &(rp->level3cnt), sizeof(__u16));
|
|
|
|
skb_put_data(skb, &(rp->datablkcnt), sizeof(__u16));
|
|
|
|
skb_put_data(skb, &(rp->datablklen), sizeof(__u16));
|
|
|
|
skb_put_data(skb, ExtFeatureDefaults, slen);
|
2012-02-20 11:52:38 +08:00
|
|
|
hycapi_applications[appl - 1].ctrl_mask |= (1 << (ctrl->cnr - 1));
|
|
|
|
hycapi_send_message(ctrl, skb);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************
|
|
|
|
hycapi_restart_internal
|
|
|
|
|
|
|
|
After an adapter has been rebootet, re-register all applications and
|
|
|
|
send a LISTEN_REQ (if there has been such a thing )
|
|
|
|
|
|
|
|
*************************************************************/
|
|
|
|
|
|
|
|
static void hycapi_restart_internal(struct capi_ctr *ctrl)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
struct sk_buff *skb;
|
|
|
|
#ifdef HYCAPI_PRINTFNAMES
|
|
|
|
printk(KERN_WARNING "HYSDN: hycapi_restart_internal");
|
|
|
|
#endif
|
2012-02-20 11:52:38 +08:00
|
|
|
for (i = 0; i < CAPI_MAXAPPL; i++) {
|
|
|
|
if (_hycapi_appCheck(i + 1, ctrl->cnr) == 1) {
|
|
|
|
hycapi_register_internal(ctrl, i + 1,
|
2005-04-17 06:20:36 +08:00
|
|
|
&hycapi_applications[i].rp);
|
2012-02-20 11:52:38 +08:00
|
|
|
if (hycapi_applications[i].listen_req[ctrl->cnr - 1]) {
|
|
|
|
skb = skb_copy(hycapi_applications[i].listen_req[ctrl->cnr - 1], GFP_ATOMIC);
|
2005-04-17 06:20:36 +08:00
|
|
|
hycapi_sendmsg_internal(ctrl, skb);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************
|
|
|
|
Register an application.
|
|
|
|
Error-checking is done for CAPI-compliance.
|
|
|
|
|
|
|
|
The application is recorded in the internal list.
|
|
|
|
*************************************************************/
|
|
|
|
|
2005-06-29 11:44:56 +08:00
|
|
|
static void
|
2012-02-20 11:52:38 +08:00
|
|
|
hycapi_register_appl(struct capi_ctr *ctrl, __u16 appl,
|
2005-04-17 06:20:36 +08:00
|
|
|
capi_register_params *rp)
|
|
|
|
{
|
|
|
|
int MaxLogicalConnections = 0, MaxBDataBlocks = 0, MaxBDataLen = 0;
|
|
|
|
hycapictrl_info *cinfo = (hycapictrl_info *)(ctrl->driverdata);
|
|
|
|
hysdn_card *card = cinfo->card;
|
|
|
|
int chk = _hycapi_appCheck(appl, ctrl->cnr);
|
2012-02-20 11:52:38 +08:00
|
|
|
if (chk < 0) {
|
2005-04-17 06:20:36 +08:00
|
|
|
return;
|
|
|
|
}
|
2012-02-20 11:52:38 +08:00
|
|
|
if (chk == 1) {
|
2005-04-17 06:20:36 +08:00
|
|
|
printk(KERN_INFO "HYSDN: apl %d already registered\n", appl);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
MaxBDataBlocks = rp->datablkcnt > CAPI_MAXDATAWINDOW ? CAPI_MAXDATAWINDOW : rp->datablkcnt;
|
|
|
|
rp->datablkcnt = MaxBDataBlocks;
|
2012-02-20 11:52:38 +08:00
|
|
|
MaxBDataLen = rp->datablklen < 1024 ? 1024 : rp->datablklen;
|
2005-04-17 06:20:36 +08:00
|
|
|
rp->datablklen = MaxBDataLen;
|
2012-02-20 11:52:38 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
MaxLogicalConnections = rp->level3cnt;
|
|
|
|
if (MaxLogicalConnections < 0) {
|
2012-02-20 11:52:38 +08:00
|
|
|
MaxLogicalConnections = card->bchans * -MaxLogicalConnections;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
if (MaxLogicalConnections == 0) {
|
|
|
|
MaxLogicalConnections = card->bchans;
|
|
|
|
}
|
2012-02-20 11:52:38 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
rp->level3cnt = MaxLogicalConnections;
|
2012-02-20 11:52:38 +08:00
|
|
|
memcpy(&hycapi_applications[appl - 1].rp,
|
2005-04-17 06:20:36 +08:00
|
|
|
rp, sizeof(capi_register_params));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
|
|
|
|
hycapi_release_internal
|
|
|
|
|
|
|
|
Send down a CAPI_RELEASE to the controller.
|
|
|
|
*********************************************************************/
|
|
|
|
|
|
|
|
static void hycapi_release_internal(struct capi_ctr *ctrl, __u16 appl)
|
|
|
|
{
|
|
|
|
hycapictrl_info *cinfo = (hycapictrl_info *)(ctrl->driverdata);
|
|
|
|
hysdn_card *card = cinfo->card;
|
|
|
|
struct sk_buff *skb;
|
|
|
|
__u16 len;
|
|
|
|
__u8 _command = 0xa1, _subcommand = 0x80;
|
|
|
|
__u16 MessageNumber = 0x0000;
|
|
|
|
|
|
|
|
capilib_release_appl(&cinfo->ncci_head, appl);
|
|
|
|
|
|
|
|
#ifdef HYCAPI_PRINTFNAMES
|
|
|
|
printk(KERN_NOTICE "hycapi_release_appl\n");
|
|
|
|
#endif
|
|
|
|
len = CAPI_MSG_BASELEN;
|
|
|
|
if (!(skb = alloc_skb(len, GFP_ATOMIC))) {
|
|
|
|
printk(KERN_ERR "HYSDN card%d: memory squeeze in hycapi_register_appl\n",
|
|
|
|
card->myid);
|
|
|
|
return;
|
|
|
|
}
|
networking: introduce and use skb_put_data()
A common pattern with skb_put() is to just want to memcpy()
some data into the new space, introduce skb_put_data() for
this.
An spatch similar to the one for skb_put_zero() converts many
of the places using it:
@@
identifier p, p2;
expression len, skb, data;
type t, t2;
@@
(
-p = skb_put(skb, len);
+p = skb_put_data(skb, data, len);
|
-p = (t)skb_put(skb, len);
+p = skb_put_data(skb, data, len);
)
(
p2 = (t2)p;
-memcpy(p2, data, len);
|
-memcpy(p, data, len);
)
@@
type t, t2;
identifier p, p2;
expression skb, data;
@@
t *p;
...
(
-p = skb_put(skb, sizeof(t));
+p = skb_put_data(skb, data, sizeof(t));
|
-p = (t *)skb_put(skb, sizeof(t));
+p = skb_put_data(skb, data, sizeof(t));
)
(
p2 = (t2)p;
-memcpy(p2, data, sizeof(*p));
|
-memcpy(p, data, sizeof(*p));
)
@@
expression skb, len, data;
@@
-memcpy(skb_put(skb, len), data, len);
+skb_put_data(skb, data, len);
(again, manually post-processed to retain some comments)
Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-06-16 20:29:20 +08:00
|
|
|
skb_put_data(skb, &len, sizeof(__u16));
|
|
|
|
skb_put_data(skb, &appl, sizeof(__u16));
|
2017-06-18 22:52:04 +08:00
|
|
|
skb_put_data(skb, &_command, sizeof(__u8));
|
|
|
|
skb_put_data(skb, &_subcommand, sizeof(__u8));
|
networking: introduce and use skb_put_data()
A common pattern with skb_put() is to just want to memcpy()
some data into the new space, introduce skb_put_data() for
this.
An spatch similar to the one for skb_put_zero() converts many
of the places using it:
@@
identifier p, p2;
expression len, skb, data;
type t, t2;
@@
(
-p = skb_put(skb, len);
+p = skb_put_data(skb, data, len);
|
-p = (t)skb_put(skb, len);
+p = skb_put_data(skb, data, len);
)
(
p2 = (t2)p;
-memcpy(p2, data, len);
|
-memcpy(p, data, len);
)
@@
type t, t2;
identifier p, p2;
expression skb, data;
@@
t *p;
...
(
-p = skb_put(skb, sizeof(t));
+p = skb_put_data(skb, data, sizeof(t));
|
-p = (t *)skb_put(skb, sizeof(t));
+p = skb_put_data(skb, data, sizeof(t));
)
(
p2 = (t2)p;
-memcpy(p2, data, sizeof(*p));
|
-memcpy(p, data, sizeof(*p));
)
@@
expression skb, len, data;
@@
-memcpy(skb_put(skb, len), data, len);
+skb_put_data(skb, data, len);
(again, manually post-processed to retain some comments)
Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-06-16 20:29:20 +08:00
|
|
|
skb_put_data(skb, &MessageNumber, sizeof(__u16));
|
2012-02-20 11:52:38 +08:00
|
|
|
hycapi_send_message(ctrl, skb);
|
|
|
|
hycapi_applications[appl - 1].ctrl_mask &= ~(1 << (ctrl->cnr - 1));
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
hycapi_release_appl
|
|
|
|
|
2012-02-20 11:52:38 +08:00
|
|
|
Release the application from the internal list an remove it's
|
2005-04-17 06:20:36 +08:00
|
|
|
registration at controller-level
|
|
|
|
******************************************************************/
|
|
|
|
|
2005-06-29 11:44:56 +08:00
|
|
|
static void
|
2005-04-17 06:20:36 +08:00
|
|
|
hycapi_release_appl(struct capi_ctr *ctrl, __u16 appl)
|
|
|
|
{
|
|
|
|
int chk;
|
|
|
|
|
|
|
|
chk = _hycapi_appCheck(appl, ctrl->cnr);
|
2012-02-20 11:52:38 +08:00
|
|
|
if (chk < 0) {
|
2005-04-17 06:20:36 +08:00
|
|
|
printk(KERN_ERR "HYCAPI: Releasing invalid appl %d on controller %d\n", appl, ctrl->cnr);
|
|
|
|
return;
|
|
|
|
}
|
2012-02-20 11:52:38 +08:00
|
|
|
if (hycapi_applications[appl - 1].listen_req[ctrl->cnr - 1]) {
|
|
|
|
kfree_skb(hycapi_applications[appl - 1].listen_req[ctrl->cnr - 1]);
|
|
|
|
hycapi_applications[appl - 1].listen_req[ctrl->cnr - 1] = NULL;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2012-02-20 11:52:38 +08:00
|
|
|
if (chk == 1)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
hycapi_release_internal(ctrl, appl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************
|
|
|
|
Kill a single controller.
|
|
|
|
**************************************************************/
|
|
|
|
|
|
|
|
int hycapi_capi_release(hysdn_card *card)
|
|
|
|
{
|
|
|
|
hycapictrl_info *cinfo = card->hyctrlinfo;
|
|
|
|
struct capi_ctr *ctrl;
|
|
|
|
#ifdef HYCAPI_PRINTFNAMES
|
|
|
|
printk(KERN_NOTICE "hycapi_capi_release\n");
|
|
|
|
#endif
|
2012-02-20 11:52:38 +08:00
|
|
|
if (cinfo) {
|
2005-04-17 06:20:36 +08:00
|
|
|
ctrl = &cinfo->capi_ctrl;
|
|
|
|
hycapi_remove_ctr(ctrl);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************
|
|
|
|
hycapi_capi_stop
|
|
|
|
|
|
|
|
Stop CAPI-Output on a card. (e.g. during reboot)
|
|
|
|
***************************************************************/
|
|
|
|
|
|
|
|
int hycapi_capi_stop(hysdn_card *card)
|
|
|
|
{
|
|
|
|
hycapictrl_info *cinfo = card->hyctrlinfo;
|
|
|
|
struct capi_ctr *ctrl;
|
|
|
|
#ifdef HYCAPI_PRINTFNAMES
|
|
|
|
printk(KERN_NOTICE "hycapi_capi_stop\n");
|
|
|
|
#endif
|
2012-02-20 11:52:38 +08:00
|
|
|
if (cinfo) {
|
2005-04-17 06:20:36 +08:00
|
|
|
ctrl = &cinfo->capi_ctrl;
|
|
|
|
/* ctrl->suspend_output(ctrl); */
|
2009-06-07 17:09:23 +08:00
|
|
|
capi_ctr_down(ctrl);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***************************************************************
|
|
|
|
hycapi_send_message
|
|
|
|
|
|
|
|
Send a message to the controller.
|
|
|
|
|
|
|
|
Messages are parsed for their Command/Subcommand-type, and appropriate
|
|
|
|
action's are performed.
|
|
|
|
|
|
|
|
Note that we have to muck around with a 64Bit-DATA_REQ as there are
|
|
|
|
firmware-releases that do not check the MsgLen-Indication!
|
|
|
|
|
|
|
|
***************************************************************/
|
|
|
|
|
2005-06-29 11:44:56 +08:00
|
|
|
static u16 hycapi_send_message(struct capi_ctr *ctrl, struct sk_buff *skb)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
__u16 appl_id;
|
|
|
|
int _len, _len2;
|
|
|
|
__u8 msghead[64];
|
|
|
|
hycapictrl_info *cinfo = ctrl->driverdata;
|
|
|
|
u16 retval = CAPI_NOERROR;
|
|
|
|
|
|
|
|
appl_id = CAPIMSG_APPID(skb->data);
|
2012-02-20 11:52:38 +08:00
|
|
|
switch (_hycapi_appCheck(appl_id, ctrl->cnr))
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2012-02-20 11:52:38 +08:00
|
|
|
case 0:
|
2005-04-17 06:20:36 +08:00
|
|
|
/* printk(KERN_INFO "Need to register\n"); */
|
2012-02-20 11:52:38 +08:00
|
|
|
hycapi_register_internal(ctrl,
|
|
|
|
appl_id,
|
|
|
|
&(hycapi_applications[appl_id - 1].rp));
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printk(KERN_ERR "HYCAPI: Controller mixup!\n");
|
|
|
|
retval = CAPI_ILLAPPNR;
|
|
|
|
goto out;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2012-02-20 11:52:38 +08:00
|
|
|
switch (CAPIMSG_CMD(skb->data)) {
|
|
|
|
case CAPI_DISCONNECT_B3_RESP:
|
|
|
|
capilib_free_ncci(&cinfo->ncci_head, appl_id,
|
|
|
|
CAPIMSG_NCCI(skb->data));
|
|
|
|
break;
|
|
|
|
case CAPI_DATA_B3_REQ:
|
|
|
|
_len = CAPIMSG_LEN(skb->data);
|
|
|
|
if (_len > 22) {
|
|
|
|
_len2 = _len - 22;
|
|
|
|
skb_copy_from_linear_data(skb, msghead, 22);
|
|
|
|
skb_copy_to_linear_data_offset(skb, _len2,
|
|
|
|
msghead, 22);
|
|
|
|
skb_pull(skb, _len2);
|
|
|
|
CAPIMSG_SETLEN(skb->data, 22);
|
|
|
|
retval = capilib_data_b3_req(&cinfo->ncci_head,
|
|
|
|
CAPIMSG_APPID(skb->data),
|
|
|
|
CAPIMSG_NCCI(skb->data),
|
|
|
|
CAPIMSG_MSGID(skb->data));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CAPI_LISTEN_REQ:
|
|
|
|
if (hycapi_applications[appl_id - 1].listen_req[ctrl->cnr - 1])
|
|
|
|
{
|
|
|
|
kfree_skb(hycapi_applications[appl_id - 1].listen_req[ctrl->cnr - 1]);
|
|
|
|
hycapi_applications[appl_id - 1].listen_req[ctrl->cnr - 1] = NULL;
|
|
|
|
}
|
|
|
|
if (!(hycapi_applications[appl_id -1].listen_req[ctrl->cnr - 1] = skb_copy(skb, GFP_ATOMIC)))
|
|
|
|
{
|
|
|
|
printk(KERN_ERR "HYSDN: memory squeeze in private_listen\n");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2012-02-20 11:52:38 +08:00
|
|
|
out:
|
2005-04-17 06:20:36 +08:00
|
|
|
if (retval == CAPI_NOERROR)
|
|
|
|
hycapi_sendmsg_internal(ctrl, skb);
|
2012-02-20 11:52:38 +08:00
|
|
|
else
|
2005-04-17 06:20:36 +08:00
|
|
|
dev_kfree_skb_any(skb);
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2010-01-14 19:10:54 +08:00
|
|
|
static int hycapi_proc_show(struct seq_file *m, void *v)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2010-01-14 19:10:54 +08:00
|
|
|
struct capi_ctr *ctrl = m->private;
|
2005-04-17 06:20:36 +08:00
|
|
|
hycapictrl_info *cinfo = (hycapictrl_info *)(ctrl->driverdata);
|
|
|
|
hysdn_card *card = cinfo->card;
|
|
|
|
char *s;
|
2010-01-14 19:10:54 +08:00
|
|
|
|
|
|
|
seq_printf(m, "%-16s %s\n", "name", cinfo->cardname);
|
|
|
|
seq_printf(m, "%-16s 0x%x\n", "io", card->iobase);
|
|
|
|
seq_printf(m, "%-16s %d\n", "irq", card->irq);
|
2012-02-20 11:52:38 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
switch (card->brdtype) {
|
2012-02-20 11:52:38 +08:00
|
|
|
case BD_PCCARD: s = "HYSDN Hycard"; break;
|
|
|
|
case BD_ERGO: s = "HYSDN Ergo2"; break;
|
|
|
|
case BD_METRO: s = "HYSDN Metro4"; break;
|
|
|
|
case BD_CHAMP2: s = "HYSDN Champ2"; break;
|
|
|
|
case BD_PLEXUS: s = "HYSDN Plexus30"; break;
|
|
|
|
default: s = "???"; break;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2010-01-14 19:10:54 +08:00
|
|
|
seq_printf(m, "%-16s %s\n", "type", s);
|
2008-05-23 06:45:07 +08:00
|
|
|
if ((s = cinfo->version[VER_DRIVER]) != NULL)
|
2010-01-14 19:10:54 +08:00
|
|
|
seq_printf(m, "%-16s %s\n", "ver_driver", s);
|
2008-05-23 06:45:07 +08:00
|
|
|
if ((s = cinfo->version[VER_CARDTYPE]) != NULL)
|
2010-01-14 19:10:54 +08:00
|
|
|
seq_printf(m, "%-16s %s\n", "ver_cardtype", s);
|
2008-05-23 06:45:07 +08:00
|
|
|
if ((s = cinfo->version[VER_SERIAL]) != NULL)
|
2010-01-14 19:10:54 +08:00
|
|
|
seq_printf(m, "%-16s %s\n", "ver_serial", s);
|
2012-02-20 11:52:38 +08:00
|
|
|
|
2010-01-14 19:10:54 +08:00
|
|
|
seq_printf(m, "%-16s %s\n", "cardname", cinfo->cardname);
|
2012-02-20 11:52:38 +08:00
|
|
|
|
2010-01-14 19:10:54 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/**************************************************************
|
|
|
|
hycapi_load_firmware
|
|
|
|
|
|
|
|
This does NOT load any firmware, but the callback somehow is needed
|
|
|
|
on capi-interface registration.
|
|
|
|
|
|
|
|
**************************************************************/
|
|
|
|
|
2005-06-29 11:44:56 +08:00
|
|
|
static int hycapi_load_firmware(struct capi_ctr *ctrl, capiloaddata *data)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
#ifdef HYCAPI_PRINTFNAMES
|
2012-02-20 11:52:38 +08:00
|
|
|
printk(KERN_NOTICE "hycapi_load_firmware\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-06-29 11:44:56 +08:00
|
|
|
static char *hycapi_procinfo(struct capi_ctr *ctrl)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
hycapictrl_info *cinfo = (hycapictrl_info *)(ctrl->driverdata);
|
|
|
|
#ifdef HYCAPI_PRINTFNAMES
|
2014-12-08 03:20:47 +08:00
|
|
|
printk(KERN_NOTICE "%s\n", __func__);
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif
|
|
|
|
if (!cinfo)
|
|
|
|
return "";
|
|
|
|
sprintf(cinfo->infobuf, "%s %s 0x%x %d %s",
|
|
|
|
cinfo->cardname[0] ? cinfo->cardname : "-",
|
|
|
|
cinfo->version[VER_DRIVER] ? cinfo->version[VER_DRIVER] : "-",
|
|
|
|
cinfo->card ? cinfo->card->iobase : 0x0,
|
|
|
|
cinfo->card ? cinfo->card->irq : 0,
|
|
|
|
hycapi_revision
|
|
|
|
);
|
|
|
|
return cinfo->infobuf;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
hycapi_rx_capipkt
|
|
|
|
|
|
|
|
Receive a capi-message.
|
|
|
|
|
|
|
|
All B3_DATA_IND are converted to 64K-extension compatible format.
|
|
|
|
New nccis are created if necessary.
|
|
|
|
*******************************************************************/
|
|
|
|
|
|
|
|
void
|
2012-02-20 11:52:38 +08:00
|
|
|
hycapi_rx_capipkt(hysdn_card *card, unsigned char *buf, unsigned short len)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
struct sk_buff *skb;
|
|
|
|
hycapictrl_info *cinfo = card->hyctrlinfo;
|
|
|
|
struct capi_ctr *ctrl;
|
|
|
|
__u16 ApplId;
|
|
|
|
__u16 MsgLen, info;
|
|
|
|
__u16 len2, CapiCmd;
|
2012-02-20 11:52:38 +08:00
|
|
|
__u32 CP64[2] = {0, 0};
|
2005-04-17 06:20:36 +08:00
|
|
|
#ifdef HYCAPI_PRINTFNAMES
|
2012-02-20 11:52:38 +08:00
|
|
|
printk(KERN_NOTICE "hycapi_rx_capipkt\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif
|
2012-02-20 11:52:38 +08:00
|
|
|
if (!cinfo) {
|
2005-04-17 06:20:36 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
ctrl = &cinfo->capi_ctrl;
|
2012-02-20 11:52:38 +08:00
|
|
|
if (len < CAPI_MSG_BASELEN) {
|
2008-02-03 21:42:53 +08:00
|
|
|
printk(KERN_ERR "HYSDN Card%d: invalid CAPI-message, length %d!\n",
|
2005-04-17 06:20:36 +08:00
|
|
|
card->myid, len);
|
|
|
|
return;
|
2012-02-20 11:52:38 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
MsgLen = CAPIMSG_LEN(buf);
|
|
|
|
ApplId = CAPIMSG_APPID(buf);
|
|
|
|
CapiCmd = CAPIMSG_CMD(buf);
|
2012-02-20 11:52:38 +08:00
|
|
|
|
|
|
|
if ((CapiCmd == CAPI_DATA_B3_IND) && (MsgLen < 30)) {
|
2005-04-17 06:20:36 +08:00
|
|
|
len2 = len + (30 - MsgLen);
|
|
|
|
if (!(skb = alloc_skb(len2, GFP_ATOMIC))) {
|
|
|
|
printk(KERN_ERR "HYSDN Card%d: incoming packet dropped\n",
|
|
|
|
card->myid);
|
|
|
|
return;
|
|
|
|
}
|
networking: introduce and use skb_put_data()
A common pattern with skb_put() is to just want to memcpy()
some data into the new space, introduce skb_put_data() for
this.
An spatch similar to the one for skb_put_zero() converts many
of the places using it:
@@
identifier p, p2;
expression len, skb, data;
type t, t2;
@@
(
-p = skb_put(skb, len);
+p = skb_put_data(skb, data, len);
|
-p = (t)skb_put(skb, len);
+p = skb_put_data(skb, data, len);
)
(
p2 = (t2)p;
-memcpy(p2, data, len);
|
-memcpy(p, data, len);
)
@@
type t, t2;
identifier p, p2;
expression skb, data;
@@
t *p;
...
(
-p = skb_put(skb, sizeof(t));
+p = skb_put_data(skb, data, sizeof(t));
|
-p = (t *)skb_put(skb, sizeof(t));
+p = skb_put_data(skb, data, sizeof(t));
)
(
p2 = (t2)p;
-memcpy(p2, data, sizeof(*p));
|
-memcpy(p, data, sizeof(*p));
)
@@
expression skb, len, data;
@@
-memcpy(skb_put(skb, len), data, len);
+skb_put_data(skb, data, len);
(again, manually post-processed to retain some comments)
Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-06-16 20:29:20 +08:00
|
|
|
skb_put_data(skb, buf, MsgLen);
|
|
|
|
skb_put_data(skb, CP64, 2 * sizeof(__u32));
|
|
|
|
skb_put_data(skb, buf + MsgLen, len - MsgLen);
|
2005-04-17 06:20:36 +08:00
|
|
|
CAPIMSG_SETLEN(skb->data, 30);
|
|
|
|
} else {
|
|
|
|
if (!(skb = alloc_skb(len, GFP_ATOMIC))) {
|
|
|
|
printk(KERN_ERR "HYSDN Card%d: incoming packet dropped\n",
|
|
|
|
card->myid);
|
|
|
|
return;
|
|
|
|
}
|
networking: introduce and use skb_put_data()
A common pattern with skb_put() is to just want to memcpy()
some data into the new space, introduce skb_put_data() for
this.
An spatch similar to the one for skb_put_zero() converts many
of the places using it:
@@
identifier p, p2;
expression len, skb, data;
type t, t2;
@@
(
-p = skb_put(skb, len);
+p = skb_put_data(skb, data, len);
|
-p = (t)skb_put(skb, len);
+p = skb_put_data(skb, data, len);
)
(
p2 = (t2)p;
-memcpy(p2, data, len);
|
-memcpy(p, data, len);
)
@@
type t, t2;
identifier p, p2;
expression skb, data;
@@
t *p;
...
(
-p = skb_put(skb, sizeof(t));
+p = skb_put_data(skb, data, sizeof(t));
|
-p = (t *)skb_put(skb, sizeof(t));
+p = skb_put_data(skb, data, sizeof(t));
)
(
p2 = (t2)p;
-memcpy(p2, data, sizeof(*p));
|
-memcpy(p, data, sizeof(*p));
)
@@
expression skb, len, data;
@@
-memcpy(skb_put(skb, len), data, len);
+skb_put_data(skb, data, len);
(again, manually post-processed to retain some comments)
Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-06-16 20:29:20 +08:00
|
|
|
skb_put_data(skb, buf, len);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2012-02-20 11:52:38 +08:00
|
|
|
switch (CAPIMSG_CMD(skb->data))
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2012-02-20 11:52:38 +08:00
|
|
|
case CAPI_CONNECT_B3_CONF:
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Check info-field for error-indication: */
|
2012-02-20 11:52:38 +08:00
|
|
|
info = CAPIMSG_U16(skb->data, 12);
|
|
|
|
switch (info)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
capilib_new_ncci(&cinfo->ncci_head, ApplId, CAPIMSG_NCCI(skb->data),
|
|
|
|
hycapi_applications[ApplId - 1].rp.datablkcnt);
|
|
|
|
|
|
|
|
break;
|
|
|
|
case 0x0001:
|
|
|
|
printk(KERN_ERR "HYSDN Card%d: NCPI not supported by current "
|
|
|
|
"protocol. NCPI ignored.\n", card->myid);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
2012-02-20 11:52:38 +08:00
|
|
|
case 0x2001:
|
|
|
|
printk(KERN_ERR "HYSDN Card%d: Message not supported in"
|
|
|
|
" current state\n", card->myid);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
2012-02-20 11:52:38 +08:00
|
|
|
case 0x2002:
|
|
|
|
printk(KERN_ERR "HYSDN Card%d: invalid PLCI\n", card->myid);
|
|
|
|
break;
|
|
|
|
case 0x2004:
|
|
|
|
printk(KERN_ERR "HYSDN Card%d: out of NCCI\n", card->myid);
|
|
|
|
break;
|
|
|
|
case 0x3008:
|
|
|
|
printk(KERN_ERR "HYSDN Card%d: NCPI not supported\n",
|
|
|
|
card->myid);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
default:
|
2012-02-20 11:52:38 +08:00
|
|
|
printk(KERN_ERR "HYSDN Card%d: Info in CONNECT_B3_CONF: %d\n",
|
|
|
|
card->myid, info);
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
2012-02-20 11:52:38 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CAPI_CONNECT_B3_IND:
|
|
|
|
capilib_new_ncci(&cinfo->ncci_head, ApplId,
|
|
|
|
CAPIMSG_NCCI(skb->data),
|
|
|
|
hycapi_applications[ApplId - 1].rp.datablkcnt);
|
|
|
|
break;
|
|
|
|
case CAPI_DATA_B3_CONF:
|
|
|
|
capilib_data_b3_conf(&cinfo->ncci_head, ApplId,
|
|
|
|
CAPIMSG_NCCI(skb->data),
|
|
|
|
CAPIMSG_MSGID(skb->data));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
capi_ctr_handle_message(ctrl, ApplId, skb);
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
hycapi_tx_capiack
|
|
|
|
|
|
|
|
Internally acknowledge a msg sent. This will remove the msg from the
|
|
|
|
internal queue.
|
|
|
|
|
|
|
|
*******************************************************************/
|
|
|
|
|
2012-02-20 11:52:38 +08:00
|
|
|
void hycapi_tx_capiack(hysdn_card *card)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
hycapictrl_info *cinfo = card->hyctrlinfo;
|
|
|
|
#ifdef HYCAPI_PRINTFNAMES
|
2012-02-20 11:52:38 +08:00
|
|
|
printk(KERN_NOTICE "hycapi_tx_capiack\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif
|
2012-02-20 11:52:38 +08:00
|
|
|
if (!cinfo) {
|
2005-04-17 06:20:36 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
spin_lock_irq(&cinfo->lock);
|
|
|
|
kfree_skb(cinfo->skbs[cinfo->out_idx]); /* free skb */
|
|
|
|
cinfo->skbs[cinfo->out_idx++] = NULL;
|
|
|
|
if (cinfo->out_idx >= HYSDN_MAX_CAPI_SKB)
|
|
|
|
cinfo->out_idx = 0; /* wrap around */
|
|
|
|
|
|
|
|
if (cinfo->sk_count-- == HYSDN_MAX_CAPI_SKB) /* dec usage count */
|
|
|
|
capi_ctr_resume_output(&cinfo->capi_ctrl);
|
|
|
|
spin_unlock_irq(&cinfo->lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***************************************************************
|
|
|
|
hycapi_tx_capiget(hysdn_card *card)
|
|
|
|
|
|
|
|
This is called when polling for messages to SEND.
|
|
|
|
|
|
|
|
****************************************************************/
|
|
|
|
|
|
|
|
struct sk_buff *
|
|
|
|
hycapi_tx_capiget(hysdn_card *card)
|
|
|
|
{
|
|
|
|
hycapictrl_info *cinfo = card->hyctrlinfo;
|
2012-02-20 11:52:38 +08:00
|
|
|
if (!cinfo) {
|
2005-04-17 06:20:36 +08:00
|
|
|
return (struct sk_buff *)NULL;
|
|
|
|
}
|
|
|
|
if (!cinfo->sk_count)
|
|
|
|
return (struct sk_buff *)NULL; /* nothing available */
|
|
|
|
|
|
|
|
return (cinfo->skbs[cinfo->out_idx]); /* next packet to send */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************
|
|
|
|
int hycapi_init()
|
|
|
|
|
|
|
|
attach the capi-driver to the kernel-capi.
|
|
|
|
|
|
|
|
***********************************************************/
|
|
|
|
|
|
|
|
int hycapi_init(void)
|
|
|
|
{
|
|
|
|
int i;
|
2012-02-20 11:52:38 +08:00
|
|
|
for (i = 0; i < CAPI_MAXAPPL; i++) {
|
2005-04-17 06:20:36 +08:00
|
|
|
memset(&(hycapi_applications[i]), 0, sizeof(hycapi_appl));
|
|
|
|
}
|
2012-02-20 11:52:38 +08:00
|
|
|
return (0);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************
|
|
|
|
hycapi_cleanup(void)
|
|
|
|
|
|
|
|
detach the capi-driver to the kernel-capi. Actually this should
|
|
|
|
free some more ressources. Do that later.
|
|
|
|
**************************************************************/
|
|
|
|
|
2012-02-20 11:52:38 +08:00
|
|
|
void
|
2005-04-17 06:20:36 +08:00
|
|
|
hycapi_cleanup(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
hycapi_capi_create(hysdn_card *card)
|
|
|
|
|
|
|
|
Attach the card with its capi-ctrl.
|
|
|
|
*********************************************************************/
|
|
|
|
|
|
|
|
static void hycapi_fill_profile(hysdn_card *card)
|
|
|
|
{
|
|
|
|
hycapictrl_info *cinfo = NULL;
|
|
|
|
struct capi_ctr *ctrl = NULL;
|
|
|
|
cinfo = card->hyctrlinfo;
|
2012-02-20 11:52:38 +08:00
|
|
|
if (!cinfo) return;
|
2005-04-17 06:20:36 +08:00
|
|
|
ctrl = &cinfo->capi_ctrl;
|
2012-02-20 11:52:38 +08:00
|
|
|
strcpy(ctrl->manu, "Hypercope");
|
2005-04-17 06:20:36 +08:00
|
|
|
ctrl->version.majorversion = 2;
|
|
|
|
ctrl->version.minorversion = 0;
|
|
|
|
ctrl->version.majormanuversion = 3;
|
|
|
|
ctrl->version.minormanuversion = 2;
|
|
|
|
ctrl->profile.ncontroller = card->myid;
|
|
|
|
ctrl->profile.nbchannel = card->bchans;
|
|
|
|
ctrl->profile.goptions = GLOBAL_OPTION_INTERNAL_CONTROLLER |
|
|
|
|
GLOBAL_OPTION_B_CHANNEL_OPERATION;
|
|
|
|
ctrl->profile.support1 = B1_PROT_64KBIT_HDLC |
|
|
|
|
(card->faxchans ? B1_PROT_T30 : 0) |
|
|
|
|
B1_PROT_64KBIT_TRANSPARENT;
|
|
|
|
ctrl->profile.support2 = B2_PROT_ISO7776 |
|
|
|
|
(card->faxchans ? B2_PROT_T30 : 0) |
|
|
|
|
B2_PROT_TRANSPARENT;
|
|
|
|
ctrl->profile.support3 = B3_PROT_TRANSPARENT |
|
|
|
|
B3_PROT_T90NL |
|
|
|
|
(card->faxchans ? B3_PROT_T30 : 0) |
|
|
|
|
(card->faxchans ? B3_PROT_T30EXT : 0) |
|
|
|
|
B3_PROT_ISO8208;
|
2012-02-20 11:52:38 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2012-02-20 11:52:38 +08:00
|
|
|
int
|
2005-04-17 06:20:36 +08:00
|
|
|
hycapi_capi_create(hysdn_card *card)
|
|
|
|
{
|
|
|
|
hycapictrl_info *cinfo = NULL;
|
|
|
|
struct capi_ctr *ctrl = NULL;
|
|
|
|
int retval;
|
|
|
|
#ifdef HYCAPI_PRINTFNAMES
|
2012-02-20 11:52:38 +08:00
|
|
|
printk(KERN_NOTICE "hycapi_capi_create\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif
|
2012-02-20 11:52:38 +08:00
|
|
|
if ((hycapi_enable & (1 << card->myid)) == 0) {
|
2005-04-17 06:20:36 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (!card->hyctrlinfo) {
|
2006-12-08 18:39:35 +08:00
|
|
|
cinfo = kzalloc(sizeof(hycapictrl_info), GFP_ATOMIC);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!cinfo) {
|
|
|
|
printk(KERN_WARNING "HYSDN: no memory for capi-ctrl.\n");
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
card->hyctrlinfo = cinfo;
|
|
|
|
cinfo->card = card;
|
|
|
|
spin_lock_init(&cinfo->lock);
|
|
|
|
INIT_LIST_HEAD(&cinfo->ncci_head);
|
|
|
|
|
|
|
|
switch (card->brdtype) {
|
2012-02-20 11:52:38 +08:00
|
|
|
case BD_PCCARD: strcpy(cinfo->cardname, "HYSDN Hycard"); break;
|
|
|
|
case BD_ERGO: strcpy(cinfo->cardname, "HYSDN Ergo2"); break;
|
|
|
|
case BD_METRO: strcpy(cinfo->cardname, "HYSDN Metro4"); break;
|
|
|
|
case BD_CHAMP2: strcpy(cinfo->cardname, "HYSDN Champ2"); break;
|
|
|
|
case BD_PLEXUS: strcpy(cinfo->cardname, "HYSDN Plexus30"); break;
|
|
|
|
default: strcpy(cinfo->cardname, "HYSDN ???"); break;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ctrl = &cinfo->capi_ctrl;
|
|
|
|
ctrl->driver_name = "hycapi";
|
|
|
|
ctrl->driverdata = cinfo;
|
|
|
|
ctrl->register_appl = hycapi_register_appl;
|
|
|
|
ctrl->release_appl = hycapi_release_appl;
|
|
|
|
ctrl->send_message = hycapi_send_message;
|
|
|
|
ctrl->load_firmware = hycapi_load_firmware;
|
|
|
|
ctrl->reset_ctr = hycapi_reset_ctr;
|
|
|
|
ctrl->procinfo = hycapi_procinfo;
|
2018-04-12 00:39:29 +08:00
|
|
|
ctrl->proc_show = hycapi_proc_show;
|
2005-04-17 06:20:36 +08:00
|
|
|
strcpy(ctrl->name, cinfo->cardname);
|
|
|
|
ctrl->owner = THIS_MODULE;
|
|
|
|
|
|
|
|
retval = attach_capi_ctr(ctrl);
|
|
|
|
if (retval) {
|
|
|
|
printk(KERN_ERR "hycapi: attach controller failed.\n");
|
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
/* fill in the blanks: */
|
|
|
|
hycapi_fill_profile(card);
|
|
|
|
capi_ctr_ready(ctrl);
|
|
|
|
} else {
|
|
|
|
/* resume output on stopped ctrl */
|
|
|
|
ctrl = &card->hyctrlinfo->capi_ctrl;
|
|
|
|
hycapi_fill_profile(card);
|
|
|
|
capi_ctr_ready(ctrl);
|
2012-02-20 11:52:38 +08:00
|
|
|
hycapi_restart_internal(ctrl);
|
2005-04-17 06:20:36 +08:00
|
|
|
/* ctrl->resume_output(ctrl); */
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|