patch-2.4.22 linux-2.4.22/include/linux/atmdev.h
Next file: linux-2.4.22/include/linux/blkdev.h
Previous file: linux-2.4.22/include/linux/atm_he.h
Back to the patch index
Back to the overall index
- Lines: 107
- Date:
2003-08-25 04:44:44.000000000 -0700
- Orig file:
linux-2.4.21/include/linux/atmdev.h
- Orig date:
2003-06-13 07:51:38.000000000 -0700
diff -urN linux-2.4.21/include/linux/atmdev.h linux-2.4.22/include/linux/atmdev.h
@@ -30,9 +30,6 @@
#define ATM_DS3_PCR (8000*12)
/* DS3: 12 cells in a 125 usec time slot */
-#define ATM_PDU_OVHD 0 /* number of bytes to charge against buffer
- quota per PDU */
-
#define ATM_SD(s) ((s)->sk->protinfo.af_atm)
@@ -292,10 +289,6 @@
struct atm_sap sap; /* SAP */
void (*push)(struct atm_vcc *vcc,struct sk_buff *skb);
void (*pop)(struct atm_vcc *vcc,struct sk_buff *skb); /* optional */
- struct sk_buff *(*alloc_tx)(struct atm_vcc *vcc,unsigned int size);
- /* TX allocation routine - can be */
- /* modified by protocol or by driver.*/
- /* NOTE: this interface will change */
int (*push_oam)(struct atm_vcc *vcc,void *cell);
int (*send)(struct atm_vcc *vcc,struct sk_buff *skb);
void *dev_data; /* per-device data */
@@ -348,6 +341,8 @@
struct k_atm_dev_stats stats; /* statistics */
char signal; /* signal status (ATM_PHY_SIG_*) */
int link_rate; /* link rate (default: OC3) */
+ atomic_t refcnt; /* reference count */
+ spinlock_t lock; /* protect internal members */
#ifdef CONFIG_PROC_FS
struct proc_dir_entry *proc_entry; /* proc entry */
char *proc_name; /* proc entry name */
@@ -388,8 +383,6 @@
void (*feedback)(struct atm_vcc *vcc,struct sk_buff *skb,
unsigned long start,unsigned long dest,int len);
int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
- void (*free_rx_skb)(struct atm_vcc *vcc, struct sk_buff *skb);
- /* @@@ temporary hack */
int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
struct module *owner;
};
@@ -404,7 +397,6 @@
struct atm_skb_data {
struct atm_vcc *vcc; /* ATM VCC */
- int iovcnt; /* 0 for "normal" operation */
unsigned long atm_options; /* ATM layer options */
};
@@ -412,7 +404,7 @@
struct atm_dev *atm_dev_register(const char *type,const struct atmdev_ops *ops,
int number,atm_dev_flags_t *flags); /* number == -1: pick first available */
-struct atm_dev *atm_find_dev(int number);
+struct atm_dev *atm_dev_lookup(int number);
void atm_dev_deregister(struct atm_dev *dev);
void shutdown_atm_dev(struct atm_dev *dev);
void bind_vcc(struct atm_vcc *vcc,struct atm_dev *dev);
@@ -423,27 +415,43 @@
*
*/
-static __inline__ int atm_guess_pdu2truesize(int pdu_size)
+static inline int atm_guess_pdu2truesize(int pdu_size)
{
return ((pdu_size+15) & ~15) + sizeof(struct sk_buff);
}
-static __inline__ void atm_force_charge(struct atm_vcc *vcc,int truesize)
+static inline void atm_force_charge(struct atm_vcc *vcc,int truesize)
+{
+ atomic_add(truesize, &vcc->sk->rmem_alloc);
+}
+
+
+static inline void atm_return(struct atm_vcc *vcc,int truesize)
{
- atomic_add(truesize+ATM_PDU_OVHD,&vcc->sk->rmem_alloc);
+ atomic_sub(truesize, &vcc->sk->rmem_alloc);
}
-static __inline__ void atm_return(struct atm_vcc *vcc,int truesize)
+static inline int atm_may_send(struct atm_vcc *vcc,unsigned int size)
{
- atomic_sub(truesize+ATM_PDU_OVHD,&vcc->sk->rmem_alloc);
+ return (size + atomic_read(&vcc->sk->wmem_alloc)) < vcc->sk->sndbuf;
}
-static __inline__ int atm_may_send(struct atm_vcc *vcc,unsigned int size)
+static inline void atm_dev_hold(struct atm_dev *dev)
{
- return size+atomic_read(&vcc->sk->wmem_alloc)+ATM_PDU_OVHD < vcc->sk->sndbuf;
+ atomic_inc(&dev->refcnt);
+}
+
+
+static inline void atm_dev_release(struct atm_dev *dev)
+{
+ atomic_dec(&dev->refcnt);
+
+ if ((atomic_read(&dev->refcnt) == 1) &&
+ test_bit(ATM_DF_CLOSE,&dev->flags))
+ shutdown_atm_dev(dev);
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)