29 #include <linux/module.h>
32 #include <linux/if_arp.h>
34 #include <linux/netdevice.h>
38 #define VERSION "arcnet: cap mode (`c') encapsulation support loaded.\n"
44 struct arcnet_local *
lp = netdev_priv(dev);
46 struct archdr *pkt = pkthdr;
47 char *pktbuf, *pkthdrbuf;
50 BUGMSG(D_DURING,
"it's a raw(cap) packet (length=%d)\n", length);
59 BUGMSG(D_NORMAL,
"Memory squeeze, dropping packet.\n");
60 dev->
stats.rx_dropped++;
65 skb_reset_mac_header(skb);
66 pkt = (
struct archdr *)skb_mac_header(skb);
75 pkthdrbuf=(
char*)pkthdr;
81 if (length >
sizeof(pkt->
soft))
82 lp->hw.copy_from_card(dev, bufnum, ofs +
sizeof(pkt->
soft),
85 length -
sizeof(pkt->
soft));
87 BUGLVL(D_SKB) arcnet_dump_skb(dev, skb,
"rx");
106 BUGMSG(D_PROTO,
"Preparing header for cap packet %x.\n",
107 *((
int*)&pkt->
soft.
cap.cookie[0]));
137 struct arcnet_local *
lp = netdev_priv(dev);
145 length -=
sizeof(
int);
147 BUGMSG(D_DURING,
"prepare_tx: txbufs=%d/%d/%d\n",
148 lp->next_tx, lp->cur_tx, bufnum);
150 BUGMSG(D_PROTO,
"Sending for cap packet %x.\n",
151 *((
int*)&pkt->
soft.
cap.cookie[0]));
155 BUGMSG(D_NORMAL,
"Bug! prepare_tx with size %d (> %d)\n",
159 if (length > MinTU) {
162 }
else if (length > MTU) {
164 hard->
offset[1] = ofs = 512 - length - 3;
168 BUGMSG(D_DURING,
"prepare_tx: length=%d ofs=%d\n",
172 lp->hw.copy_to_card(dev, bufnum, 0, hard,
ARC_HDR_SIZE);
173 lp->hw.copy_to_card(dev, bufnum, ofs, &pkt->
soft.
cap.proto,
178 lp->hw.copy_to_card(dev, bufnum, ofs+1,
179 ((
unsigned char*)&pkt->
soft.
cap.mes),length-1);
181 lp->lastload_dest = hard->
dest;
186 static int ack_tx(
struct net_device *dev,
int acked)
188 struct arcnet_local *lp = netdev_priv(dev);
191 int length=
sizeof(
struct arc_cap);
193 BUGMSG(D_DURING,
"capmode: ack_tx: protocol: %x: result: %d\n",
194 lp->outgoing.skb->protocol, acked);
196 BUGLVL(D_SKB) arcnet_dump_skb(dev, lp->outgoing.skb, "ack_tx");
201 BUGMSG(D_NORMAL,
"Memory squeeze, can't acknowledge.\n");
208 skb_reset_mac_header(ackskb);
209 ackpkt = (
struct archdr *)skb_mac_header(ackskb);
212 skb_copy_from_linear_data(lp->outgoing.skb, ackpkt,
215 ackpkt->
soft.
cap.mes.ack=acked;
217 BUGMSG(D_PROTO,
"Ackknowledge for cap packet %x.\n",
218 *((
int*)&ackpkt->
soft.
cap.cookie[0]));
222 BUGLVL(D_SKB) arcnet_dump_skb(dev, ackskb, "ack_tx_recv");
232 static
struct ArcProto capmode_proto =
244 static void arcnet_cap_init(
void)
248 for (count = 1; count <= 8; count++)
260 static int __init capmode_module_init(
void)
267 static void __exit capmode_module_exit(
void)