Something went wrong. Try again.
(I'm so sorry!) Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269/* SPDX-License-Identifier: GPL-2.0 *//* atmdev.h - ATM device driver declarations and various related items */#ifndef LINUX_ATMDEV_H#define LINUX_ATMDEV_H
#include <linux/wait.h> /* wait_queue_head_t */#include <linux/time.h> /* struct timeval */#include <linux/net.h>#include <linux/bug.h>#include <linux/skbuff.h> /* struct sk_buff */#include <linux/uio.h>#include <net/sock.h>#include <linux/atomic.h>#include <linux/refcount.h>#include <uapi/linux/atmdev.h>
#ifdef CONFIG_PROC_FS#include <linux/proc_fs.h>
extern struct proc_dir_entry *atm_proc_root;#endif
#ifdef CONFIG_COMPAT#include <linux/compat.h>struct compat_atm_iobuf { int length; compat_uptr_t buffer;};#endif
struct k_atm_aal_stats {#define __HANDLE_ITEM(i) atomic_t i __AAL_STAT_ITEMS#undef __HANDLE_ITEM};
struct k_atm_dev_stats { struct k_atm_aal_stats aal0; struct k_atm_aal_stats aal34; struct k_atm_aal_stats aal5;};
struct device;
enum { ATM_VF_ADDR, /* Address is in use. Set by anybody, cleared by device driver. */ ATM_VF_READY, /* VC is ready to transfer data. Set by device driver, cleared by anybody. */ ATM_VF_PARTIAL, /* resources are bound to PVC (partial PVC setup), controlled by socket layer */ ATM_VF_HASQOS, /* QOS parameters have been set */ ATM_VF_CLOSE, /* asynchronous close - VC is being torn down */};
enum { ATM_DF_REMOVED, /* device was removed from atm_devs list */};
#define ATM_PHY_SIG_LOST 0 /* no carrier/light */#define ATM_PHY_SIG_UNKNOWN 1 /* carrier/light status is unknown */#define ATM_PHY_SIG_FOUND 2 /* carrier/light okay */
#define ATM_ATMOPT_CLP 1 /* set CLP bit */
struct atm_vcc { /* struct sock has to be the first member of atm_vcc */ struct sock sk; unsigned long flags; /* VCC flags (ATM_VF_*) */ short vpi; /* VPI and VCI (types must be equal */ /* with sockaddr) */ int vci; unsigned long aal_options; /* AAL layer options */ unsigned long atm_options; /* ATM layer options */ struct atm_dev *dev; /* device back pointer */ struct atm_qos qos; /* QOS */ void (*release_cb)(struct atm_vcc *vcc); /* release_sock callback */ void (*push)(struct atm_vcc *vcc,struct sk_buff *skb); void (*pop)(struct atm_vcc *vcc,struct sk_buff *skb); /* optional */ int (*send)(struct atm_vcc *vcc,struct sk_buff *skb); void *dev_data; /* per-device data */ void *proto_data; /* per-protocol data */ struct k_atm_aal_stats *stats; /* pointer to AAL stats group */ struct module *owner; /* owner of ->push function */ void *user_back; /* user backlink - not touched by the */ /* native ATM stack, used by sch_atm */};
static inline struct atm_vcc *atm_sk(struct sock *sk){ return (struct atm_vcc *)sk;}
static inline struct atm_vcc *ATM_SD(struct socket *sock){ return atm_sk(sock->sk);}
static inline struct sock *sk_atm(struct atm_vcc *vcc){ return (struct sock *)vcc;}
struct atm_dev { const struct atmdev_ops *ops; /* device operations; NULL if unused */ const char *type; /* device type name */ int number; /* device index */ void *dev_data; /* per-device data */ void *phy_data; /* private PHY data */ unsigned long flags; /* device flags (ATM_DF_*) */ unsigned char esi[ESI_LEN]; /* ESI ("MAC" addr) */ struct atm_cirange ci_range; /* VPI/VCI range */ struct k_atm_dev_stats stats; /* statistics */ char signal; /* signal status (ATM_PHY_SIG_*) */ int link_rate; /* link rate (default: OC3) */ refcount_t refcnt; /* reference count */#ifdef CONFIG_PROC_FS struct proc_dir_entry *proc_entry; /* proc entry */ char *proc_name; /* proc entry name */#endif struct device class_dev; /* sysfs device */ struct list_head dev_list; /* linkage */};
struct atmdev_ops { /* only send is required */ void (*dev_close)(struct atm_dev *dev); int (*open)(struct atm_vcc *vcc); void (*close)(struct atm_vcc *vcc); int (*ioctl)(struct atm_dev *dev,unsigned int cmd,void __user *arg);#ifdef CONFIG_COMPAT int (*compat_ioctl)(struct atm_dev *dev,unsigned int cmd, void __user *arg);#endif int (*send)(struct atm_vcc *vcc,struct sk_buff *skb); int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page); struct module *owner;};
struct atm_skb_data { struct atm_vcc *vcc; /* ATM VCC */ unsigned long atm_options; /* ATM layer options */ unsigned int acct_truesize; /* truesize accounted to vcc */} __packed;
#define VCC_HTABLE_SIZE 32
extern struct hlist_head vcc_hash[VCC_HTABLE_SIZE];extern rwlock_t vcc_sklist_lock;
#define ATM_SKB(skb) (((struct atm_skb_data *) (skb)->cb))
struct atm_dev *atm_dev_register(const char *type, struct device *parent, const struct atmdev_ops *ops, int number, /* -1 == pick first available */ unsigned long *flags);struct atm_dev *atm_dev_lookup(int number);void atm_dev_deregister(struct atm_dev *dev);
/* atm_dev_signal_change * * Propagate lower layer signal change in atm_dev->signal to netdevice. * The event will be sent via a notifier call chain. */void atm_dev_signal_change(struct atm_dev *dev, char signal);
void vcc_insert_socket(struct sock *sk);
void atm_dev_release_vccs(struct atm_dev *dev);
static inline void atm_account_tx(struct atm_vcc *vcc, struct sk_buff *skb){ /* * Because ATM skbs may not belong to a sock (and we don't * necessarily want to), skb->truesize may be adjusted, * escaping the hack in pskb_expand_head() which avoids * doing so for some cases. So stash the value of truesize * at the time we accounted it, and atm_pop_raw() can use * that value later, in case it changes. */ refcount_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc); ATM_SKB(skb)->acct_truesize = skb->truesize; ATM_SKB(skb)->atm_options = vcc->atm_options;}
static inline void atm_return_tx(struct atm_vcc *vcc, struct sk_buff *skb){ WARN_ON_ONCE(refcount_sub_and_test(ATM_SKB(skb)->acct_truesize, &sk_atm(vcc)->sk_wmem_alloc));}
static inline void atm_force_charge(struct atm_vcc *vcc,int truesize){ atomic_add(truesize, &sk_atm(vcc)->sk_rmem_alloc);}
static inline void atm_return(struct atm_vcc *vcc,int truesize){ atomic_sub(truesize, &sk_atm(vcc)->sk_rmem_alloc);}
static inline int atm_may_send(struct atm_vcc *vcc,unsigned int size){ return (size + refcount_read(&sk_atm(vcc)->sk_wmem_alloc)) < sk_atm(vcc)->sk_sndbuf;}
static inline void atm_dev_hold(struct atm_dev *dev){ refcount_inc(&dev->refcnt);}
static inline void atm_dev_put(struct atm_dev *dev){ if (refcount_dec_and_test(&dev->refcnt)) { BUG_ON(!test_bit(ATM_DF_REMOVED, &dev->flags)); if (dev->ops->dev_close) dev->ops->dev_close(dev); put_device(&dev->class_dev); }}
int atm_charge(struct atm_vcc *vcc,int truesize);
void vcc_release_async(struct atm_vcc *vcc, int reply);
struct atm_ioctl { struct module *owner; /* A module reference is kept if appropriate over this call. * Return -ENOIOCTLCMD if you don't handle it. */ int (*ioctl)(struct socket *, unsigned int cmd, unsigned long arg); struct list_head list;};
/** * register_atm_ioctl - register handler for ioctl operations * @ioctl: ioctl handler to register * * Special (non-device) handlers of ioctl's should * register here. If you're a normal device, you should * set .ioctl in your atmdev_ops instead. */void register_atm_ioctl(struct atm_ioctl *ioctl);
/** * deregister_atm_ioctl - remove the ioctl handler * @ioctl: ioctl handler to deregister */void deregister_atm_ioctl(struct atm_ioctl *ioctl);
/* register_atmdevice_notifier - register atm_dev notify events * * Clients like br2684 will register notify events * Currently we notify of signal found/lost */int register_atmdevice_notifier(struct notifier_block *nb);void unregister_atmdevice_notifier(struct notifier_block *nb);
#endif