cregit-Linux how code gets into the kernel

Release 4.11 net/atm/mpc.c

Directory: net/atm

#define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__

#include <linux/kernel.h>
#include <linux/string.h>
#include <linux/slab.h>
#include <linux/timer.h>
#include <linux/init.h>
#include <linux/bitops.h>
#include <linux/capability.h>
#include <linux/seq_file.h>

/* We are an ethernet device */
#include <linux/if_ether.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <net/sock.h>
#include <linux/skbuff.h>
#include <linux/ip.h>
#include <linux/uaccess.h>
#include <asm/byteorder.h>
#include <net/checksum.h>   /* for ip_fast_csum() */
#include <net/arp.h>
#include <net/dst.h>
#include <linux/proc_fs.h>

/* And atm device */
#include <linux/atmdev.h>
#include <linux/atmlec.h>
#include <linux/atmmpc.h>
/* Modular too */
#include <linux/module.h>

#include "lec.h"
#include "mpc.h"
#include "resources.h"

/*
 * mpc.c: Implementation of MPOA client kernel part
 */

#if 0
#define dprintk(format, args...) \
	printk(KERN_DEBUG "mpoa:%s: " format, __func__, ##args)
#define dprintk_cont(format, args...) printk(KERN_CONT format, ##args)
#else

#define dprintk(format, args...)					\
	do { if (0)                                                     \
                printk(KERN_DEBUG "mpoa:%s: " format, __func__, ##args);\
        } while (0)

#define dprintk_cont(format, args...)			\
	do { if (0) printk(KERN_CONT format, ##args); } while (0)
#endif

#if 0
#define ddprintk(format, args...) \
	printk(KERN_DEBUG "mpoa:%s: " format, __func__, ##args)
#define ddprintk_cont(format, args...) printk(KERN_CONT format, ##args)
#else

#define ddprintk(format, args...)					\
	do { if (0)                                                     \
                printk(KERN_DEBUG "mpoa:%s: " format, __func__, ##args);\
        } while (0)

#define ddprintk_cont(format, args...)			\
	do { if (0) printk(KERN_CONT format, ##args); } while (0)
#endif

/* mpc_daemon -> kernel */
static void MPOA_trigger_rcvd(struct k_message *msg, struct mpoa_client *mpc);
static void MPOA_res_reply_rcvd(struct k_message *msg, struct mpoa_client *mpc);
static void ingress_purge_rcvd(struct k_message *msg, struct mpoa_client *mpc);
static void egress_purge_rcvd(struct k_message *msg, struct mpoa_client *mpc);
static void mps_death(struct k_message *msg, struct mpoa_client *mpc);
static void clean_up(struct k_message *msg, struct mpoa_client *mpc,
		     int action);
static void MPOA_cache_impos_rcvd(struct k_message *msg,
				  struct mpoa_client *mpc);
static void set_mpc_ctrl_addr_rcvd(struct k_message *mesg,
				   struct mpoa_client *mpc);
static void set_mps_mac_addr_rcvd(struct k_message *mesg,
				  struct mpoa_client *mpc);

static const uint8_t *copy_macs(struct mpoa_client *mpc,
				const uint8_t *router_mac,
				const uint8_t *tlvs, uint8_t mps_macs,
				uint8_t device_type);
static void purge_egress_shortcut(struct atm_vcc *vcc, eg_cache_entry *entry);

static void send_set_mps_ctrl_addr(const char *addr, struct mpoa_client *mpc);
static void mpoad_close(struct atm_vcc *vcc);
static int msg_from_mpoad(struct atm_vcc *vcc, struct sk_buff *skb);

static void mpc_push(struct atm_vcc *vcc, struct sk_buff *skb);
static netdev_tx_t mpc_send_packet(struct sk_buff *skb,
				   struct net_device *dev);
static int mpoa_event_listener(struct notifier_block *mpoa_notifier,
			       unsigned long event, void *dev);
static void mpc_timer_refresh(void);
static void mpc_cache_check(unsigned long checking_time);


static struct llc_snap_hdr llc_snap_mpoa_ctrl = {
	0xaa, 0xaa, 0x03,
	{0x00, 0x00, 0x5e},
	{0x00, 0x03}         /* For MPOA control PDUs */
};

static struct llc_snap_hdr llc_snap_mpoa_data = {
	0xaa, 0xaa, 0x03,
	{0x00, 0x00, 0x00},
	{0x08, 0x00}         /* This is for IP PDUs only */
};

static struct llc_snap_hdr llc_snap_mpoa_data_tagged = {
	0xaa, 0xaa, 0x03,
	{0x00, 0x00, 0x00},
	{0x88, 0x4c}         /* This is for tagged data PDUs */
};


static struct notifier_block mpoa_notifier = {
	mpoa_event_listener,
	NULL,
	0
};


struct mpoa_client *mpcs = NULL; 
/* FIXME */

static struct atm_mpoa_qos *qos_head = NULL;
static DEFINE_TIMER(mpc_timer, NULL, 0, 0);



static struct mpoa_client *find_mpc_by_itfnum(int itf) { struct mpoa_client *mpc; mpc = mpcs; /* our global linked list */ while (mpc != NULL) { if (mpc->dev_num == itf) return mpc; mpc = mpc->next; } return NULL; /* not found */ }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)50100.00%1100.00%
Total50100.00%1100.00%


static struct mpoa_client *find_mpc_by_vcc(struct atm_vcc *vcc) { struct mpoa_client *mpc; mpc = mpcs; /* our global linked list */ while (mpc != NULL) { if (mpc->mpoad_vcc == vcc) return mpc; mpc = mpc->next; } return NULL; /* not found */ }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)52100.00%1100.00%
Total52100.00%1100.00%


static struct mpoa_client *find_mpc_by_lec(struct net_device *dev) { struct mpoa_client *mpc; mpc = mpcs; /* our global linked list */ while (mpc != NULL) { if (mpc->dev == dev) return mpc; mpc = mpc->next; } return NULL; /* not found */ }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)52100.00%1100.00%
Total52100.00%1100.00%

/* * Functions for managing QoS list */ /* * Overwrites the old entry or makes a new one. */
struct atm_mpoa_qos *atm_mpoa_add_qos(__be32 dst_ip, struct atm_qos *qos) { struct atm_mpoa_qos *entry; entry = atm_mpoa_search_qos(dst_ip); if (entry != NULL) { entry->qos = *qos; return entry; } entry = kmalloc(sizeof(struct atm_mpoa_qos), GFP_KERNEL); if (entry == NULL) { pr_info("mpoa: out of memory\n"); return entry; } entry->ipaddr = dst_ip; entry->qos = *qos; entry->next = qos_head; qos_head = entry; return entry; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)9797.00%250.00%
Joe Perches22.00%125.00%
Al Viro11.00%125.00%
Total100100.00%4100.00%


struct atm_mpoa_qos *atm_mpoa_search_qos(__be32 dst_ip) { struct atm_mpoa_qos *qos; qos = qos_head; while (qos) { if (qos->ipaddr == dst_ip) break; qos = qos->next; } return qos; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)4297.67%150.00%
Al Viro12.33%150.00%
Total43100.00%2100.00%

/* * Returns 0 for failure */
int atm_mpoa_delete_qos(struct atm_mpoa_qos *entry) { struct atm_mpoa_qos *curr; if (entry == NULL) return 0; if (entry == qos_head) { qos_head = qos_head->next; kfree(entry); return 1; } curr = qos_head; while (curr != NULL) { if (curr->next == entry) { curr->next = entry->next; kfree(entry); return 1; } curr = curr->next; } return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)93100.00%1100.00%
Total93100.00%1100.00%

/* this is buggered - we need locking for qos_head */
void atm_mpoa_disp_qos(struct seq_file *m) { struct atm_mpoa_qos *qos; qos = qos_head; seq_printf(m, "QoS entries for shortcuts:\n"); seq_printf(m, "IP address\n TX:max_pcr pcr min_pcr max_cdv max_sdu\n RX:max_pcr pcr min_pcr max_cdv max_sdu\n"); while (qos != NULL) { seq_printf(m, "%pI4\n %-7d %-7d %-7d %-7d %-7d\n %-7d %-7d %-7d %-7d %-7d\n", &qos->ipaddr, qos->qos.txtp.max_pcr, qos->qos.txtp.pcr, qos->qos.txtp.min_pcr, qos->qos.txtp.max_cdv, qos->qos.txtp.max_sdu, qos->qos.rxtp.max_pcr, qos->qos.rxtp.pcr, qos->qos.rxtp.min_pcr, qos->qos.rxtp.max_cdv, qos->qos.rxtp.max_sdu); qos = qos->next; } }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)12690.65%125.00%
Al Viro117.91%250.00%
Harvey Harrison21.44%125.00%
Total139100.00%4100.00%


static struct net_device *find_lec_by_itfnum(int itf) { struct net_device *dev; char name[IFNAMSIZ]; sprintf(name, "lec%d", itf); dev = dev_get_by_name(&init_net, name); return dev; }

Contributors

PersonTokensPropCommitsCommitProp
Chas Williams2659.09%250.00%
Linus Torvalds (pre-git)1534.09%125.00%
Eric W. Biedermann36.82%125.00%
Total44100.00%4100.00%


static struct mpoa_client *alloc_mpc(void) { struct mpoa_client *mpc; mpc = kzalloc(sizeof(struct mpoa_client), GFP_KERNEL); if (mpc == NULL) return NULL; rwlock_init(&mpc->ingress_lock); rwlock_init(&mpc->egress_lock); mpc->next = mpcs; atm_mpoa_init_cache(mpc); mpc->parameters.mpc_p1 = MPC_P1; mpc->parameters.mpc_p2 = MPC_P2; memset(mpc->parameters.mpc_p3, 0, sizeof(mpc->parameters.mpc_p3)); mpc->parameters.mpc_p4 = MPC_P4; mpc->parameters.mpc_p5 = MPC_P5; mpc->parameters.mpc_p6 = MPC_P6; mpcs = mpc; return mpc; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)12293.13%250.00%
Andrew Morton86.11%125.00%
Panagiotis Issaris10.76%125.00%
Total131100.00%4100.00%

/* * * start_mpc() puts the MPC on line. All the packets destined * to the lec underneath us are now being monitored and * shortcuts will be established. * */
static void start_mpc(struct mpoa_client *mpc, struct net_device *dev) { dprintk("(%s)\n", mpc->dev->name); if (!dev->netdev_ops) pr_info("(%s) not starting\n", dev->name); else { mpc->old_ops = dev->netdev_ops; mpc->new_ops = *mpc->old_ops; mpc->new_ops.ndo_start_xmit = mpc_send_packet; dev->netdev_ops = &mpc->new_ops; } }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)4860.00%125.00%
Stephen Hemminger2936.25%125.00%
Joe Perches33.75%250.00%
Total80100.00%4100.00%


static void stop_mpc(struct mpoa_client *mpc) { struct net_device *dev = mpc->dev; dprintk("(%s)", mpc->dev->name); /* Lets not nullify lec device's dev->hard_start_xmit */ if (dev->netdev_ops != &mpc->new_ops) { dprintk_cont(" mpc already stopped, not fatal\n"); return; } dprintk_cont("\n"); dev->netdev_ops = mpc->old_ops; mpc->old_ops = NULL; /* close_shortcuts(mpc); ??? FIXME */ }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)5171.83%133.33%
Stephen Hemminger1723.94%133.33%
Joe Perches34.23%133.33%
Total71100.00%3100.00%

static const char *mpoa_device_type_string(char type) __attribute__ ((unused));
static const char *mpoa_device_type_string(char type) { switch (type) { case NON_MPOA: return "non-MPOA device"; case MPS: return "MPS"; case MPC: return "MPC"; case MPS_AND_MPC: return "both MPS and MPC"; } return "unspecified (non-MPOA) device"; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)4193.18%133.33%
David S. Miller24.55%133.33%
Joe Perches12.27%133.33%
Total44100.00%3100.00%

/* * lec device calls this via its netdev_priv(dev)->lane2_ops * ->associate_indicator() when it sees a TLV in LE_ARP packet. * We fill in the pointer above when we see a LANE2 lec initializing * See LANE2 spec 3.1.5 * * Quite a big and ugly function but when you look at it * all it does is to try to locate and parse MPOA Device * Type TLV. * We give our lec a pointer to this function and when the * lec sees a TLV it uses the pointer to call this function. * */
static void lane2_assoc_ind(struct net_device *dev, const u8 *mac_addr, const u8 *tlvs, u32 sizeoftlvs) { uint32_t type; uint8_t length, mpoa_device_type, number_of_mps_macs; const uint8_t *end_of_tlvs; struct mpoa_client *mpc; mpoa_device_type = number_of_mps_macs = 0; /* silence gcc */ dprintk("(%s) received TLV(s), ", dev->name); dprintk("total length of all TLVs %d\n", sizeoftlvs); mpc = find_mpc_by_lec(dev); /* Sampo-Fix: moved here from below */ if (mpc == NULL) { pr_info("(%s) no mpc\n", dev->name); return; } end_of_tlvs = tlvs + sizeoftlvs; while (end_of_tlvs - tlvs >= 5) { type = ((tlvs[0] << 24) | (tlvs[1] << 16) | (tlvs[2] << 8) | tlvs[3]); length = tlvs[4]; tlvs += 5; dprintk(" type 0x%x length %02x\n", type, length); if (tlvs + length > end_of_tlvs) { pr_info("TLV value extends past its buffer, aborting parse\n"); return; } if (type == 0) { pr_info("mpoa: (%s) TLV type was 0, returning\n", dev->name); return; } if (type != TLV_MPOA_DEVICE_TYPE) { tlvs += length; continue; /* skip other TLVs */ } mpoa_device_type = *tlvs++; number_of_mps_macs = *tlvs++; dprintk("(%s) MPOA device type '%s', ", dev->name, mpoa_device_type_string(mpoa_device_type)); if (mpoa_device_type == MPS_AND_MPC && length < (42 + number_of_mps_macs*ETH_ALEN)) { /* :) */ pr_info("(%s) short MPOA Device Type TLV\n", dev->name); continue; } if ((mpoa_device_type == MPS || mpoa_device_type == MPC) && length < 22 + number_of_mps_macs*ETH_ALEN) { pr_info("(%s) short MPOA Device Type TLV\n", dev->name); continue; } if (mpoa_device_type != MPS && mpoa_device_type != MPS_AND_MPC) { dprintk("ignoring non-MPS device "); if (mpoa_device_type == MPC) tlvs += 20; continue; /* we are only interested in MPSs */ } if (number_of_mps_macs == 0 && mpoa_device_type == MPS_AND_MPC) { pr_info("(%s) MPS_AND_MPC has zero MACs\n", dev->name); continue; /* someone should read the spec */ } dprintk_cont("this MPS has %d MAC addresses\n", number_of_mps_macs); /* * ok, now we can go and tell our daemon * the control address of MPS */ send_set_mps_ctrl_addr(tlvs, mpc); tlvs = copy_macs(mpc, mac_addr, tlvs, number_of_mps_macs, mpoa_device_type); if (tlvs == NULL) return; } if (end_of_tlvs - tlvs != 0) pr_info("(%s) ignoring %zd bytes of trailing TLV garbage\n", dev->name, end_of_tlvs - tlvs); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)38493.66%120.00%
Joe Perches194.63%240.00%
David Howells61.46%120.00%
Alexey Dobriyan10.24%120.00%
Total410100.00%5100.00%

/* * Store at least advertizing router's MAC address * plus the possible MAC address(es) to mpc->mps_macs. * For a freshly allocated MPOA client mpc->mps_macs == 0. */
static const uint8_t *copy_macs(struct mpoa_client *mpc, const uint8_t *router_mac, const uint8_t *tlvs, uint8_t mps_macs, uint8_t device_type) { int num_macs; num_macs = (mps_macs > 1) ? mps_macs : 1; if (mpc->number_of_mps_macs != num_macs) { /* need to reallocate? */ if (mpc->number_of_mps_macs != 0) kfree(mpc->mps_macs); mpc->number_of_mps_macs = 0; mpc->mps_macs = kmalloc(num_macs * ETH_ALEN, GFP_KERNEL); if (mpc->mps_macs == NULL) { pr_info("(%s) out of mem\n", mpc->dev->name); return NULL; } } ether_addr_copy(mpc->mps_macs, router_mac); tlvs += 20; if (device_type == MPS_AND_MPC) tlvs += 20; if (mps_macs > 0) memcpy(mpc->mps_macs, tlvs, mps_macs*ETH_ALEN); tlvs += mps_macs*ETH_ALEN; mpc->number_of_mps_macs = num_macs; return tlvs; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)16496.47%125.00%
Joe Perches31.76%250.00%
David Howells31.76%125.00%
Total170100.00%4100.00%


static int send_via_shortcut(struct sk_buff *skb, struct mpoa_client *mpc) { in_cache_entry *entry; struct iphdr *iph; char *buff; __be32 ipaddr = 0; static struct { struct llc_snap_hdr hdr; __be32 tag; } tagged_llc_snap_hdr = { {0xaa, 0xaa, 0x03, {0x00, 0x00, 0x00}, {0x88, 0x4c}}, 0 }; buff = skb->data + mpc->dev->hard_header_len; iph = (struct iphdr *)buff; ipaddr = iph->daddr; ddprintk("(%s) ipaddr 0x%x\n", mpc->dev->name, ipaddr); entry = mpc->in_ops->get(ipaddr, mpc); if (entry == NULL) { entry = mpc->in_ops->add_entry(ipaddr, mpc); if (entry != NULL) mpc->in_ops->put(entry); return 1; } /* threshold not exceeded or VCC not ready */ if (mpc->in_ops->cache_hit(entry, mpc) != OPEN) { ddprintk("(%s) cache_hit: returns != OPEN\n", mpc->dev->name); mpc->in_ops->put(entry); return 1; } ddprintk("(%s) using shortcut\n", mpc->dev->name); /* MPOA spec A.1.4, MPOA client must decrement IP ttl at least by one */ if (iph->ttl <= 1) { ddprintk("(%s) IP ttl = %u, using LANE\n", mpc->dev->name, iph->ttl); mpc->in_ops->put(entry); return 1; } iph->ttl--; iph->check = 0; iph->check = ip_fast_csum((unsigned char *)iph, iph->ihl); if (entry->ctrl_info.tag != 0) { ddprintk("(%s) adding tag 0x%x\n", mpc->dev->name, entry->ctrl_info.tag); tagged_llc_snap_hdr.tag = entry->ctrl_info.tag; skb_pull(skb, ETH_HLEN); /* get rid of Eth header */ skb_push(skb, sizeof(tagged_llc_snap_hdr)); /* add LLC/SNAP header */ skb_copy_to_linear_data(skb, &tagged_llc_snap_hdr, sizeof(tagged_llc_snap_hdr)); } else { skb_pull(skb, ETH_HLEN); /* get rid of Eth header */ skb_push(skb, sizeof(struct llc_snap_hdr)); /* add LLC/SNAP header + tag */ skb_copy_to_linear_data(skb, &llc_snap_mpoa_data, sizeof(struct llc_snap_hdr)); } atomic_add(skb->truesize, &sk_atm(entry->shortcut)->sk_wmem_alloc); ATM_SKB(skb)->atm_options = entry->shortcut->atm_options; entry->shortcut->send(entry->shortcut, skb); entry->packets_fwded++; mpc->in_ops->put(entry); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)43796.68%222.22%
Arnaldo Carvalho de Melo61.33%333.33%
Joe Perches61.33%222.22%
Al Viro20.44%111.11%
Chas Williams10.22%111.11%
Total452100.00%9100.00%

/* * Probably needs some error checks and locking, not sure... */
static netdev_tx_t mpc_send_packet(struct sk_buff *skb, struct net_device *dev) { struct mpoa_client *mpc; struct ethhdr *eth; int i = 0; mpc = find_mpc_by_lec(dev); /* this should NEVER fail */ if (mpc == NULL) { pr_info("(%s) no MPC found\n", dev->name); goto non_ip; } eth = (struct ethhdr *)skb->data; if (eth->h_proto != htons(ETH_P_IP)) goto non_ip; /* Multi-Protocol Over ATM :-) */ /* Weed out funny packets (e.g., AF_PACKET or raw). */ if (skb->len < ETH_HLEN + sizeof(struct iphdr)) goto non_ip; skb_set_network_header(skb, ETH_HLEN); if (skb->len < ETH_HLEN + ip_hdr(skb)->ihl * 4 || ip_hdr(skb)->ihl < 5) goto non_ip; while (i < mpc->number_of_mps_macs) { if (ether_addr_equal(eth->h_dest, mpc->mps_macs + i * ETH_ALEN)) if (send_via_shortcut(skb, mpc) == 0) /* try shortcut */ return NETDEV_TX_OK; i++; } non_ip: return __netdev_start_xmit(mpc->old_ops, skb, dev, false); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)13467.00%111.11%
Herbert Xu5427.00%111.11%
David S. Miller52.50%222.22%
Joe Perches31.50%222.22%
Stephen Hemminger31.50%222.22%
Patrick McHardy10.50%111.11%
Total200100.00%9100.00%


static int atm_mpoa_vcc_attach(struct atm_vcc *vcc, void __user *arg) { int bytes_left; struct mpoa_client *mpc; struct atmmpc_ioc ioc_data; in_cache_entry *in_entry; __be32 ipaddr; bytes_left = copy_from_user(&ioc_data, arg, sizeof(struct atmmpc_ioc)); if (bytes_left != 0) { pr_info("mpoa:Short read (missed %d bytes) from userland\n", bytes_left); return -EFAULT; } ipaddr = ioc_data.ipaddr; if (ioc_data.dev_num < 0 || ioc_data.dev_num >= MAX_LEC_ITF) return -EINVAL; mpc = find_mpc_by_itfnum(ioc_data.dev_num); if (mpc == NULL) return -EINVAL; if (ioc_data.type == MPC_SOCKET_INGRESS) { in_entry = mpc->in_ops->get(ipaddr, mpc); if (in_entry == NULL || in_entry->entry_state < INGRESS_RESOLVED) { pr_info("(%s) did not find RESOLVED entry from ingress cache\n", mpc->dev->name); if (in_entry != NULL) mpc->in_ops->put(in_entry); return -EINVAL; } pr_info("(%s) attaching ingress SVC, entry = %pI4\n", mpc->dev->name, &in_entry->ctrl_info.in_dst_ip); in_entry->shortcut = vcc; mpc->in_ops->put(in_entry); } else { pr_info("(%s) attaching egress SVC\n", mpc->dev->name); } vcc->proto_data = mpc->dev; vcc->push = mpc_push; return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)22491.80%225.00%
Al Viro104.10%337.50%
Joe Perches83.28%112.50%
Chas Williams10.41%112.50%
Harvey Harrison10.41%112.50%
Total244100.00%8100.00%

/* * */
static void mpc_vcc_close(struct atm_vcc *vcc, struct net_device *dev) { struct mpoa_client *mpc; in_cache_entry *in_entry; eg_cache_entry *eg_entry; mpc = find_mpc_by_lec(dev); if (mpc == NULL) { pr_info("(%s) close for unknown MPC\n", dev->name); return; } dprintk("(%s)\n", dev->name); in_entry = mpc->in_ops->get_by_vcc(vcc, mpc); if (in_entry) { dprintk("(%s) ingress SVC closed ip = %pI4\n", mpc->dev->name, &in_entry->ctrl_info.in_dst_ip); in_entry->shortcut = NULL; mpc->in_ops->put(in_entry); } eg_entry = mpc->eg_ops->get_by_vcc(vcc, mpc); if (eg_entry) { dprintk("(%s) egress SVC closed\n", mpc->dev->name); eg_entry->shortcut = NULL; mpc->eg_ops->put(eg_entry); } if (in_entry == NULL && eg_entry == NULL) dprintk("(%s) unused vcc closed\n", dev->name); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)16692.74%233.33%
Al Viro63.35%116.67%
Joe Perches63.35%233.33%
Harvey Harrison10.56%116.67%
Total179100.00%6100.00%


static void mpc_push(struct atm_vcc *vcc, struct sk_buff *skb) { struct net_device *dev = (struct net_device *)vcc->proto_data; struct sk_buff *new_skb; eg_cache_entry *eg; struct mpoa_client *mpc; __be32 tag; char *tmp; ddprintk("(%s)\n", dev->name); if (skb == NULL) { dprintk("(%s) null skb, closing VCC\n", dev->name); mpc_vcc_close(vcc, dev); return; } skb->dev = dev; if (memcmp(skb->data, &llc_snap_mpoa_ctrl, sizeof(struct llc_snap_hdr)) == 0) { struct sock *sk = sk_atm(vcc); dprintk("(%s) control packet arrived\n", dev->name); /* Pass control packets to daemon */ skb_queue_tail(&sk->sk_receive_queue, skb); sk->sk_data_ready(sk); return; } /* data coming over the shortcut */ atm_return(vcc, skb->truesize); mpc = find_mpc_by_lec(dev); if (mpc == NULL) { pr_info("(%s) unknown MPC\n", dev->name); return; } if (memcmp(skb->data, &llc_snap_mpoa_data_tagged, sizeof(struct llc_snap_hdr)) == 0) { /* MPOA tagged data */ ddprintk("(%s) tagged data packet arrived\n", dev->name); } else if (memcmp(skb->data, &llc_snap_mpoa_data, sizeof(struct llc_snap_hdr)) == 0) { /* MPOA data */ pr_info("(%s) Unsupported non-tagged data packet arrived. Purging\n", dev->name); dev_kfree_skb_any(skb); return; } else { pr_info("(%s) garbage arrived, purging\n", dev->name); dev_kfree_skb_any(skb); return; } tmp = skb->data + sizeof(struct llc_snap_hdr); tag = *(__be32 *)tmp; eg = mpc->eg_ops->get_by_tag(tag, mpc); if (eg == NULL) { pr_info("mpoa: (%s) Didn't find egress cache entry, tag = %u\n", dev->name, tag); purge_egress_shortcut(vcc, NULL); dev_kfree_skb_any(skb); return; } /* * See if ingress MPC is using shortcut we opened as a return channel. * This means we have a bi-directional vcc opened by us. */ if (eg->shortcut == NULL) { eg->shortcut = vcc; pr_info("(%s) egress SVC in use\n", dev->name); } skb_pull(skb, sizeof(struct llc_snap_hdr) + sizeof(tag)); /* get rid of LLC/SNAP header */ new_skb = skb_realloc_headroom(skb, eg->ctrl_info.DH_length); /* LLC/SNAP is shorter than MAC header :( */ dev_kfree_skb_any(skb); if (new_skb == NULL) { mpc->eg_ops->put(eg); return; } skb_push(new_skb, eg->ctrl_info.DH_length); /* add MAC header */ skb_copy_to_linear_data(new_skb, eg->ctrl_info.DLL_header, eg->ctrl_info.DH_length); new_skb->protocol = eth_type_trans(new_skb, dev); skb_reset_network_header(new_skb); eg->latest_ip_addr = ip_hdr(new_skb)->saddr; eg->packets_rcvd++; mpc->eg_ops->put(eg); memset(ATM_SKB(new_skb), 0, sizeof(struct atm_skb_data)); netif_rx(new_skb); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)45588.87%213.33%
Chas Williams214.10%426.67%
Arnaldo Carvalho de Melo193.71%533.33%
Joe Perches142.73%213.33%
Al Viro20.39%16.67%
Jiri Slaby10.20%16.67%
Total512100.00%15100.00%

static struct atmdev_ops mpc_ops = { /* only send is required */ .close = mpoad_close, .send = msg_from_mpoad }; static struct atm_dev mpc_dev = { .ops = &mpc_ops, .type = "mpc", .number = 42, .lock = __SPIN_LOCK_UNLOCKED(mpc_dev.lock) /* members not explicitly initialised will be 0 */ };
static int atm_mpoa_mpoad_attach(struct atm_vcc *vcc, int arg) { struct mpoa_client *mpc; struct lec_priv *priv; int err; if (mpcs == NULL) { init_timer(&mpc_timer); mpc_timer_refresh(); /* This lets us now how our LECs are doing */ err = register_netdevice_notifier(&mpoa_notifier); if (err < 0) { del_timer(&mpc_timer); return err; } } mpc = find_mpc_by_itfnum(arg); if (mpc == NULL) { dprintk("allocating new mpc for itf %d\n", arg); mpc = alloc_mpc(); if (mpc == NULL) return -ENOMEM; mpc->dev_num = arg; mpc->dev = find_lec_by_itfnum(arg); /* NULL if there was no lec */ } if (mpc->mpoad_vcc) { pr_info("mpoad is already present for itf %d\n", arg); return -EADDRINUSE; } if (mpc->dev) { /* check if the lec is LANE2 capable */ priv = netdev_priv(mpc->dev); if (priv->lane_version < 2) { dev_put(mpc->dev); mpc->dev = NULL; } else priv->lane2_ops->associate_indicator = lane2_assoc_ind; } mpc->mpoad_vcc = vcc; vcc->dev = &mpc_dev; vcc_insert_socket(sk_atm(vcc)); set_bit(ATM_VF_META, &vcc->flags); set_bit(ATM_VF_READY, &vcc->flags); if (mpc->dev) { char empty[ATM_ESA_LEN]; memset(empty, 0, ATM_ESA_LEN); start_mpc(mpc, mpc->dev); /* set address if mpcd e.g. gets killed and restarted. * If we do not do it now we have to wait for the next LE_ARP */ if (memcmp(mpc->mps_ctrl_addr, empty, ATM_ESA_LEN) != 0) send_set_mps_ctrl_addr(mpc->mps_ctrl_addr, mpc); } __module_get(THIS_MODULE); return arg; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)23679.19%325.00%
Maximilian Attems227.38%18.33%
Chas Williams217.05%325.00%
Linus Torvalds103.36%18.33%
Arnaldo Carvalho de Melo31.01%18.33%
Joe Perches31.01%216.67%
Wang Chen31.01%18.33%
Total298100.00%12100.00%


static void send_set_mps_ctrl_addr(const char *addr, struct mpoa_client *mpc) { struct k_message mesg; memcpy(mpc->mps_ctrl_addr, addr, ATM_ESA_LEN); mesg.type = SET_MPS_CTRL_ADDR; memcpy(mesg.MPS_ctrl, addr, ATM_ESA_LEN); msg_to_mpoad(&mesg, mpc); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)5598.21%150.00%
David Howells11.79%150.00%
Total56100.00%2100.00%


static void mpoad_close(struct atm_vcc *vcc) { struct mpoa_client *mpc; struct sk_buff *skb; mpc = find_mpc_by_vcc(vcc); if (mpc == NULL) { pr_info("did not find MPC\n"); return; } if (!mpc->mpoad_vcc) { pr_info("close for non-present mpoad\n"); return; } mpc->mpoad_vcc = NULL; if (mpc->dev) { struct lec_priv *priv = netdev_priv(mpc->dev); priv->lane2_ops->associate_indicator = NULL; stop_mpc(mpc); dev_put(mpc->dev); } mpc->in_ops->destroy_cache(mpc); mpc->eg_ops->destroy_cache(mpc); while ((skb = skb_dequeue(&sk_atm(vcc)->sk_receive_queue))) { atm_return(vcc, skb->truesize); kfree_skb(skb); } pr_info("(%s) going down\n", (mpc->dev) ? mpc->dev->name : "<unknown>"); module_put(THIS_MODULE); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)15385.96%225.00%
Chas Williams126.74%225.00%
Joe Perches63.37%112.50%
Arnaldo Carvalho de Melo42.25%225.00%
Wang Chen31.69%112.50%
Total178100.00%8100.00%

/* * */
static int msg_from_mpoad(struct atm_vcc *vcc, struct sk_buff *skb) { struct mpoa_client *mpc = find_mpc_by_vcc(vcc); struct k_message *mesg = (struct k_message *)skb->data; atomic_sub(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc); if (mpc == NULL) { pr_info("no mpc found\n"); return 0; } dprintk("(%s)", mpc->dev ? mpc->dev->name : "<unknown>"); switch (mesg->type) { case MPOA_RES_REPLY_RCVD: dprintk_cont("mpoa_res_reply_rcvd\n"); MPOA_res_reply_rcvd(mesg, mpc); break; case MPOA_TRIGGER_RCVD: dprintk_cont("mpoa_trigger_rcvd\n"); MPOA_trigger_rcvd(mesg, mpc); break; case INGRESS_PURGE_RCVD: dprintk_cont("nhrp_purge_rcvd\n"); ingress_purge_rcvd(mesg, mpc); break; case EGRESS_PURGE_RCVD: dprintk_cont("egress_purge_reply_rcvd\n"); egress_purge_rcvd(mesg, mpc); break; case MPS_DEATH: dprintk_cont("mps_death\n"); mps_death(mesg, mpc); break; case CACHE_IMPOS_RCVD: dprintk_cont("cache_impos_rcvd\n"); MPOA_cache_impos_rcvd(mesg, mpc); break; case SET_MPC_CTRL_ADDR: dprintk_cont("set_mpc_ctrl_addr\n"); set_mpc_ctrl_addr_rcvd(mesg, mpc); break; case SET_MPS_MAC_ADDR: dprintk_cont("set_mps_mac_addr\n"); set_mps_mac_addr_rcvd(mesg, mpc); break; case CLEAN_UP_AND_EXIT: dprintk_cont("clean_up_and_exit\n"); clean_up(mesg, mpc, DIE); break; case RELOAD: dprintk_cont("reload\n"); clean_up(mesg, mpc, RELOAD); break; case SET_MPC_PARAMS: dprintk_cont("set_mpc_params\n"); mpc->parameters = mesg->content.params; break; default: dprintk_cont("unknown message %d\n", mesg->type); break; } kfree_skb(skb); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)26689.26%116.67%
Joe Perches279.06%233.33%
Arnaldo Carvalho de Melo41.34%233.33%
Chas Williams10.34%116.67%
Total298100.00%6100.00%

/* Remember that this function may not do things that sleep */
int msg_to_mpoad(struct k_message *mesg, struct mpoa_client *mpc) { struct sk_buff *skb; struct sock *sk; if (mpc == NULL || !mpc->mpoad_vcc) { pr_info("mesg %d to a non-existent mpoad\n", mesg->type); return -ENXIO; } skb = alloc_skb(sizeof(struct k_message), GFP_ATOMIC); if (skb == NULL) return -ENOMEM; skb_put(skb, sizeof(struct k_message)); skb_copy_to_linear_data(skb, mesg, sizeof(*mesg)); atm_force_charge(mpc->mpoad_vcc, skb->truesize); sk = sk_atm(mpc->mpoad_vcc); skb_queue_tail(&sk->sk_receive_queue, skb); sk->sk_data_ready(sk); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)11381.88%112.50%
Arnaldo Carvalho de Melo1712.32%337.50%
Chas Williams64.35%337.50%
Joe Perches21.45%112.50%
Total138100.00%8100.00%


static int mpoa_event_listener(struct notifier_block *mpoa_notifier, unsigned long event, void *ptr) { struct net_device *dev = netdev_notifier_info_to_dev(ptr); struct mpoa_client *mpc; struct lec_priv *priv; if (!net_eq(dev_net(dev), &init_net)) return NOTIFY_DONE; if (strncmp(dev->name, "lec", 3)) return NOTIFY_DONE; /* we are only interested in lec:s */ switch (event) { case NETDEV_REGISTER: /* a new lec device was allocated */ priv = netdev_priv(dev); if (priv->lane_version < 2) break; priv->lane2_ops->associate_indicator = lane2_assoc_ind; mpc = find_mpc_by_itfnum(priv->itfnum); if (mpc == NULL) { dprintk("allocating new mpc for %s\n", dev->name); mpc = alloc_mpc(); if (mpc == NULL) { pr_info("no new mpc"); break; } } mpc->dev_num = priv->itfnum; mpc->dev = dev; dev_hold(dev); dprintk("(%s) was initialized\n", dev->name); break; case NETDEV_UNREGISTER: /* the lec device was deallocated */ mpc = find_mpc_by_lec(dev); if (mpc == NULL) break; dprintk("device (%s) was deallocated\n", dev->name); stop_mpc(mpc); dev_put(mpc->dev); mpc->dev = NULL; break; case NETDEV_UP: /* the dev was ifconfig'ed up */ mpc = find_mpc_by_lec(dev); if (mpc == NULL) break; if (mpc->mpoad_vcc != NULL) start_mpc(mpc, dev); break; case NETDEV_DOWN: /* the dev was ifconfig'ed down */ /* this means that the flow of packets from the * upper layer stops */ mpc = find_mpc_by_lec(dev); if (mpc == NULL) break; if (mpc->mpoad_vcc != NULL) stop_mpc(mpc); break; case NETDEV_REBOOT: case NETDEV_CHANGE: case NETDEV_CHANGEMTU: case NETDEV_CHANGEADDR: case NETDEV_GOING_DOWN: break; default: break; } return NOTIFY_DONE; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)27386.67%220.00%
Chas Williams123.81%110.00%
Eric W. Biedermann82.54%110.00%
Hideaki Yoshifuji / 吉藤英明82.54%220.00%
Jiri Pirko61.90%110.00%
Joe Perches51.59%220.00%
Wang Chen30.95%110.00%
Total315100.00%10100.00%

/* * Functions which are called after a message is received from mpcd. * Msg is reused on purpose. */
static void MPOA_trigger_rcvd(struct k_message *msg, struct mpoa_client *mpc) { __be32 dst_ip = msg->content.in_info.in_dst_ip; in_cache_entry *entry; entry = mpc->in_ops->get(dst_ip, mpc); if (entry == NULL) { entry = mpc->in_ops->add_entry(dst_ip, mpc); entry->entry_state = INGRESS_RESOLVING; msg->type = SND_MPOA_RES_RQST; msg->content.in_info = entry->ctrl_info; msg_to_mpoad(msg, mpc); do_gettimeofday(&(entry->reply_wait)); mpc->in_ops->put(entry); return; } if (entry->entry_state == INGRESS_INVALID) { entry->entry_state = INGRESS_RESOLVING; msg->type = SND_MPOA_RES_RQST; msg->content.in_info = entry->ctrl_info; msg_to_mpoad(msg, mpc); do_gettimeofday(&(entry->reply_wait)); mpc->in_ops->put(entry); return; } pr_info("(%s) entry already in resolving state\n", (mpc->dev) ? mpc->dev->name : "<unknown>"); mpc->in_ops->put(entry); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)19898.51%250.00%
Joe Perches21.00%125.00%
Al Viro10.50%125.00%
Total201100.00%4100.00%

/* * Things get complicated because we have to check if there's an egress * shortcut with suitable traffic parameters we could use. */
static void check_qos_and_open_shortcut(struct k_message *msg, struct mpoa_client *client, in_cache_entry *entry) { __be32 dst_ip = msg->content.in_info.in_dst_ip; struct atm_mpoa_qos *qos = atm_mpoa_search_qos(dst_ip); eg_cache_entry *eg_entry = client->eg_ops->get_by_src_ip(dst_ip, client); if (eg_entry && eg_entry->shortcut) { if (eg_entry->shortcut->qos.txtp.traffic_class & msg->qos.txtp.traffic_class & (qos ? qos->qos.txtp.traffic_class : ATM_UBR | ATM_CBR)) { if (eg_entry->shortcut->qos.txtp.traffic_class == ATM_UBR) entry->shortcut = eg_entry->shortcut; else if (eg_entry->shortcut->qos.txtp.max_pcr > 0) entry->shortcut = eg_entry->shortcut; } if (entry->shortcut) { dprintk("(%s) using egress SVC to reach %pI4\n", client->dev->name, &dst_ip); client->eg_ops->put(eg_entry); return; } } if (eg_entry != NULL) client->eg_ops->put(eg_entry); /* No luck in the egress cache we must open an ingress SVC */ msg->type = OPEN_INGRESS_SVC; if (qos && (qos->qos.txtp.traffic_class == msg->qos.txtp.traffic_class)) { msg->qos = qos->qos; pr_info("(%s) trying to get a CBR shortcut\n", client->dev->name); } else memset(&msg->qos, 0, sizeof(struct atm_qos)); msg_to_mpoad(msg, client); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)26497.78%228.57%
Joe Perches31.11%228.57%
Al Viro20.74%228.57%
Harvey Harrison10.37%114.29%
Total270100.00%7100.00%


static void MPOA_res_reply_rcvd(struct k_message *msg, struct mpoa_client *mpc) { __be32 dst_ip = msg->content.in_info.in_dst_ip; in_cache_entry *entry = mpc->in_ops->get(dst_ip, mpc); dprintk("(%s) ip %pI4\n", mpc->dev->name, &dst_ip); ddprintk("(%s) entry = %p", mpc->dev->name, entry); if (entry == NULL) { pr_info("(%s) ARGH, received res. reply for an entry that doesn't exist.\n", mpc->dev->name); return; } ddprintk_cont(" entry_state = %d ", entry->entry_state); if (entry->entry_state == INGRESS_RESOLVED) { pr_info("(%s) RESOLVED entry!\n", mpc->dev->name); mpc->in_ops->put(entry); return; } entry->ctrl_info = msg->content.in_info; do_gettimeofday(&(entry->tv)); do_gettimeofday(&(entry->reply_wait)); /* Used in refreshing func from now on */ entry->refresh_time = 0; ddprintk_cont("entry->shortcut = %p\n", entry->shortcut); if (entry->entry_state == INGRESS_RESOLVING && entry->shortcut != NULL) { entry->entry_state = INGRESS_RESOLVED; mpc->in_ops->put(entry); return; /* Shortcut already open... */ } if (entry->shortcut != NULL) { pr_info("(%s) entry->shortcut != NULL, impossible!\n", mpc->dev->name); mpc->in_ops->put(entry); return; } check_qos_and_open_shortcut(msg, mpc, entry); entry->entry_state = INGRESS_RESOLVED; mpc->in_ops->put(entry); return; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)25195.08%228.57%
Joe Perches103.79%228.57%
Al Viro20.76%228.57%
Harvey Harrison10.38%114.29%
Total264100.00%7100.00%


static void ingress_purge_rcvd(struct k_message *msg, struct mpoa_client *mpc) { __be32 dst_ip = msg->content.in_info.in_dst_ip; __be32 mask = msg->ip_mask; in_cache_entry *entry = mpc->in_ops->get_with_mask(dst_ip, mpc, mask); if (entry == NULL) { pr_info("(%s) purge for a non-existing entry, ip = %pI4\n", mpc->dev->name, &dst_ip); return; } do { dprintk("(%s) removing an ingress entry, ip = %pI4\n", mpc->dev->name, &dst_ip); write_lock_bh(&mpc->ingress_lock); mpc->in_ops->remove_entry(entry, mpc); write_unlock_bh(&mpc->ingress_lock); mpc->in_ops->put(entry); entry = mpc->in_ops->get_with_mask(dst_ip, mpc, mask); } while (entry != NULL); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)13892.62%228.57%
Al Viro64.03%228.57%
Joe Perches32.01%228.57%
Harvey Harrison21.34%114.29%
Total149100.00%7100.00%


static void egress_purge_rcvd(struct k_message *msg, struct mpoa_client *mpc) { __be32 cache_id = msg->content.eg_info.cache_id; eg_cache_entry *entry = mpc->eg_ops->get_by_cache_id(cache_id, mpc); if (entry == NULL) { dprintk("(%s) purge for a non-existing entry\n", mpc->dev->name); return; } write_lock_irq(&mpc->egress_lock); mpc->eg_ops->remove_entry(entry, mpc); write_unlock_irq(&mpc->egress_lock); mpc->eg_ops->put(entry); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)9697.96%250.00%
Joe Perches11.02%125.00%
Al Viro11.02%125.00%
Total98100.00%4100.00%


static void purge_egress_shortcut(struct atm_vcc *vcc, eg_cache_entry *entry) { struct sock *sk; struct k_message *purge_msg; struct sk_buff *skb; dprintk("entering\n"); if (vcc == NULL) { pr_info("vcc == NULL\n"); return; } skb = alloc_skb(sizeof(struct k_message), GFP_ATOMIC); if (skb == NULL) { pr_info("out of memory\n"); return; } skb_put(skb, sizeof(struct k_message)); memset(skb->data, 0, sizeof(struct k_message)); purge_msg = (struct k_message *)skb->data; purge_msg->type = DATA_PLANE_PURGE; if (entry != NULL) purge_msg->content.eg_info = entry->ctrl_info; atm_force_charge(vcc, skb->truesize); sk = sk_atm(vcc); skb_queue_tail(&sk->sk_receive_queue, skb); sk->sk_data_ready(sk); dprintk("exiting\n"); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)14885.55%112.50%
Arnaldo Carvalho de Melo137.51%225.00%
Joe Perches63.47%225.00%
Chas Williams63.47%337.50%
Total173100.00%8100.00%

/* * Our MPS died. Tell our daemon to send NHRP data plane purge to each * of the egress shortcuts we have. */
static void mps_death(struct k_message *msg, struct mpoa_client *mpc) { eg_cache_entry *entry; dprintk("(%s)\n", mpc->dev->name); if (memcmp(msg->MPS_ctrl, mpc->mps_ctrl_addr, ATM_ESA_LEN)) { pr_info("(%s) wrong MPS\n", mpc->dev->name); return; } /* FIXME: This knows too much of the cache structure */ read_lock_irq(&mpc->egress_lock); entry = mpc->eg_cache; while (entry != NULL) { purge_egress_shortcut(entry->shortcut, entry); entry = entry->next; } read_unlock_irq(&mpc->egress_lock); mpc->in_ops->destroy_cache(mpc); mpc->eg_ops->destroy_cache(mpc); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)12197.58%250.00%
Joe Perches32.42%250.00%
Total124100.00%4100.00%


static void MPOA_cache_impos_rcvd(struct k_message *msg, struct mpoa_client *mpc) { uint16_t holding_time; eg_cache_entry *entry = mpc->eg_ops->get_by_cache_id(msg->content.eg_info.cache_id, mpc); holding_time = msg->content.eg_info.holding_time; dprintk("(%s) entry = %p, holding_time = %u\n", mpc->dev->name, entry, holding_time); if (entry == NULL && holding_time) { entry = mpc->eg_ops->add_entry(msg, mpc); mpc->eg_ops->put(entry); return; } if (holding_time) { mpc->eg_ops->update(entry, holding_time); return; } write_lock_irq(&mpc->egress_lock); mpc->eg_ops->remove_entry(entry, mpc); write_unlock_irq(&mpc->egress_lock); mpc->eg_ops->put(entry); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)15199.34%266.67%
Joe Perches10.66%133.33%
Total152100.00%3100.00%


static void set_mpc_ctrl_addr_rcvd(struct k_message *mesg, struct mpoa_client *mpc) { struct lec_priv *priv; int i, retval ; uint8_t tlv[4 + 1 + 1 + 1 + ATM_ESA_LEN]; tlv[0] = 00; tlv[1] = 0xa0; tlv[2] = 0x3e; tlv[3] = 0x2a; /* type */ tlv[4] = 1 + 1 + ATM_ESA_LEN; /* length */ tlv[5] = 0x02; /* MPOA client */ tlv[6] = 0x00; /* number of MPS MAC addresses */ memcpy(&tlv[7], mesg->MPS_ctrl, ATM_ESA_LEN); /* MPC ctrl ATM addr */ memcpy(mpc->our_ctrl_addr, mesg->MPS_ctrl, ATM_ESA_LEN); dprintk("(%s) setting MPC ctrl ATM address to", mpc->dev ? mpc->dev->name : "<unknown>"); for (i = 7; i < sizeof(tlv); i++) dprintk_cont(" %02x", tlv[i]); dprintk_cont("\n"); if (mpc->dev) { priv = netdev_priv(mpc->dev); retval = priv->lane2_ops->associate_req(mpc->dev, mpc->dev->dev_addr, tlv, sizeof(tlv)); if (retval == 0) pr_info("(%s) MPOA device type TLV association failed\n", mpc->dev->name); retval = priv->lane2_ops->resolve(mpc->dev, NULL, 1, NULL, NULL); if (retval < 0) pr_info("(%s) targetless LE_ARP request failed\n", mpc->dev->name); } }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)26195.96%125.00%
Joe Perches82.94%250.00%
Wang Chen31.10%125.00%
Total272100.00%4100.00%


static void set_mps_mac_addr_rcvd(struct k_message *msg, struct mpoa_client *client) { if (client->number_of_mps_macs) kfree(client->mps_macs); client->number_of_mps_macs = 0; client->mps_macs = kmemdup(msg->MPS_ctrl, ETH_ALEN, GFP_KERNEL); if (client->mps_macs == NULL) { pr_info("out of memory\n"); return; } client->number_of_mps_macs = 1; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)6590.28%133.33%
Arnaldo Carvalho de Melo56.94%133.33%
Joe Perches22.78%133.33%
Total72100.00%3100.00%

/* * purge egress cache and tell daemon to 'action' (DIE, RELOAD) */
static void clean_up(struct k_message *msg, struct mpoa_client *mpc, int action) { eg_cache_entry *entry; msg->type = SND_EGRESS_PURGE; /* FIXME: This knows too much of the cache structure */ read_lock_irq(&mpc->egress_lock); entry = mpc->eg_cache; while (entry != NULL) { msg->content.eg_info = entry->ctrl_info; dprintk("cache_id %u\n", entry->ctrl_info.cache_id); msg_to_mpoad(msg, mpc); entry = entry->next; } read_unlock_irq(&mpc->egress_lock); msg->type = action; msg_to_mpoad(msg, mpc); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)10699.07%266.67%
Joe Perches10.93%133.33%
Total107100.00%3100.00%


static void mpc_timer_refresh(void) { mpc_timer.expires = jiffies + (MPC_P2 * HZ); mpc_timer.data = mpc_timer.expires; mpc_timer.function = mpc_cache_check; add_timer(&mpc_timer); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)3792.50%150.00%
Al Viro37.50%150.00%
Total40100.00%2100.00%


static void mpc_cache_check(unsigned long checking_time) { struct mpoa_client *mpc = mpcs; static unsigned long previous_resolving_check_time; static unsigned long previous_refresh_time; while (mpc != NULL) { mpc->in_ops->clear_count(mpc); mpc->eg_ops->clear_expired(mpc); if (checking_time - previous_resolving_check_time > mpc->parameters.mpc_p4 * HZ) { mpc->in_ops->check_resolving(mpc); previous_resolving_check_time = checking_time; } if (checking_time - previous_refresh_time > mpc->parameters.mpc_p5 * HZ) { mpc->in_ops->refresh(mpc); previous_refresh_time = checking_time; } mpc = mpc->next; } mpc_timer_refresh(); }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)120100.00%1100.00%
Total120100.00%1100.00%


static int atm_mpoa_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) { int err = 0; struct atm_vcc *vcc = ATM_SD(sock); if (cmd != ATMMPC_CTRL && cmd != ATMMPC_DATA) return -ENOIOCTLCMD; if (!capable(CAP_NET_ADMIN)) return -EPERM; switch (cmd) { case ATMMPC_CTRL: err = atm_mpoa_mpoad_attach(vcc, (int)arg); if (err >= 0) sock->state = SS_CONNECTED; break; case ATMMPC_DATA: err = atm_mpoa_vcc_attach(vcc, (void __user *)arg); break; default: break; } return err; }

Contributors

PersonTokensPropCommitsCommitProp
Chas Williams10690.60%250.00%
Linus Torvalds (pre-git)65.13%125.00%
Al Viro54.27%125.00%
Total117100.00%4100.00%

static struct atm_ioctl atm_ioctl_ops = { .owner = THIS_MODULE, .ioctl = atm_mpoa_ioctl, };
static __init int atm_mpoa_init(void) { register_atm_ioctl(&atm_ioctl_ops); if (mpc_proc_init() != 0) pr_info("failed to initialize /proc/mpoa\n"); pr_info("mpc.c: initialized\n"); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)1851.43%116.67%
Chas Williams1337.14%233.33%
Joe Perches38.57%233.33%
Michal Marek12.86%116.67%
Total35100.00%6100.00%


static void __exit atm_mpoa_cleanup(void) { struct mpoa_client *mpc, *tmp; struct atm_mpoa_qos *qos, *nextqos; struct lec_priv *priv; mpc_proc_clean(); del_timer_sync(&mpc_timer); unregister_netdevice_notifier(&mpoa_notifier); deregister_atm_ioctl(&atm_ioctl_ops); mpc = mpcs; mpcs = NULL; while (mpc != NULL) { tmp = mpc->next; if (mpc->dev != NULL) { stop_mpc(mpc); priv = netdev_priv(mpc->dev); if (priv->lane2_ops != NULL) priv->lane2_ops->associate_indicator = NULL; } ddprintk("about to clear caches\n"); mpc->in_ops->destroy_cache(mpc); mpc->eg_ops->destroy_cache(mpc); ddprintk("caches cleared\n"); kfree(mpc->mps_macs); memset(mpc, 0, sizeof(struct mpoa_client)); ddprintk("about to kfree %p\n", mpc); kfree(mpc); ddprintk("next mpc is at %p\n", tmp); mpc = tmp; } qos = qos_head; qos_head = NULL; while (qos != NULL) { nextqos = qos->next; dprintk("freeing qos entry %p\n", qos); kfree(qos); qos = nextqos; } }

Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)20592.34%225.00%
Chas Williams83.60%337.50%
Joe Perches52.25%112.50%
Wang Chen31.35%112.50%
Julia Lawall10.45%112.50%
Total222100.00%8100.00%

module_init(atm_mpoa_init); module_exit(atm_mpoa_cleanup); MODULE_LICENSE("GPL");

Overall Contributors

PersonTokensPropCommitsCommitProp
Linus Torvalds (pre-git)657987.97%57.58%
Chas Williams2643.53%1015.15%
Joe Perches2303.08%57.58%
Arnaldo Carvalho de Melo801.07%710.61%
Al Viro570.76%57.58%
Herbert Xu540.72%11.52%
Stephen Hemminger500.67%23.03%
Maximilian Attems220.29%11.52%
David S. Miller220.29%46.06%
Wang Chen160.21%23.03%
Andrew Morton150.20%23.03%
Linus Torvalds150.20%23.03%
David Howells140.19%11.52%
Eric W. Biedermann110.15%23.03%
Hideaki Yoshifuji / 吉藤英明110.15%34.55%
Harvey Harrison80.11%11.52%
Jiri Pirko60.08%11.52%
Ingo Molnar40.05%11.52%
Milind Arun Choudhary40.05%11.52%
Rusty Russell40.05%11.52%
Tejun Heo30.04%11.52%
Randy Dunlap30.04%11.52%
Patrick McHardy10.01%11.52%
Alexey Dobriyan10.01%11.52%
Michal Marek10.01%11.52%
Jiri Slaby10.01%11.52%
Panagiotis Issaris10.01%11.52%
Julia Lawall10.01%11.52%
Steven Cole10.01%11.52%
Total7479100.00%66100.00%
Directory: net/atm
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.