* [PATCH net-next-2.6 v5 5/5] sctp: Add ASCONF operation on the single-homed host
From: Michio Honda @ 2011-04-25 15:24 UTC (permalink / raw)
To: netdev; +Cc: lksctp-developers
SCTP can change the IP address on the single-homed host.
In this case, the SCTP association transmits an ASCONF packet including addition of the new IP address and deletion of the old address. This patch implements this functionality.
In this case, the ASCONF chunk is added to the beginning of the queue, because the other chunks cannot be transmitted in this state.
Signed-off-by: Michio Honda <micchie@sfc.wide.ad.jp>
---
diff --git a/include/net/sctp/constants.h b/include/net/sctp/constants.h
index c70d8cc..d7a4ee3 100644
--- a/include/net/sctp/constants.h
+++ b/include/net/sctp/constants.h
@@ -441,4 +441,8 @@ enum {
*/
#define SCTP_AUTH_RANDOM_LENGTH 32
+/* ASCONF PARAMETERS */
+#define SCTP_ASCONF_V4_PARAM_LEN 16
+#define SCTP_ASCONF_V6_PARAM_LEN 28
+
#endif /* __sctp_constants_h__ */
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index cc9185c..db4e9d0 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -1901,6 +1901,8 @@ struct sctp_association {
* after reaching 4294967295.
*/
__u32 addip_serial;
+ union sctp_addr *asconf_addr_del_pending;
+ int src_out_of_asoc_ok;
/* SCTP AUTH: list of the endpoint shared keys. These
* keys are provided out of band by the user applicaton
diff --git a/net/sctp/associola.c b/net/sctp/associola.c
index 6b04287..2082d0a 100644
--- a/net/sctp/associola.c
+++ b/net/sctp/associola.c
@@ -279,6 +279,8 @@ static struct sctp_association *sctp_association_init(struct sctp_association *a
asoc->peer.asconf_capable = 0;
if (sctp_addip_noauth)
asoc->peer.asconf_capable = 1;
+ asoc->asconf_addr_del_pending = NULL;
+ asoc->src_out_of_asoc_ok = 0;
/* Create an input queue. */
sctp_inq_init(&asoc->base.inqueue);
@@ -443,6 +445,10 @@ void sctp_association_free(struct sctp_association *asoc)
asoc->peer.transport_count = 0;
+ /* Free pending address space being deleted */
+ if (asoc->asconf_addr_del_pending != NULL)
+ kfree(asoc->asconf_addr_del_pending);
+
/* Free any cached ASCONF_ACK chunk. */
sctp_assoc_free_asconf_acks(asoc);
diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
index 865ce7b..56c97ce 100644
--- a/net/sctp/ipv6.c
+++ b/net/sctp/ipv6.c
@@ -332,6 +332,13 @@ static void sctp_v6_get_saddr(struct sctp_sock *sk,
matchlen = bmatchlen;
}
}
+ if (laddr->state == SCTP_ADDR_NEW && asoc->src_out_of_asoc_ok) {
+ bmatchlen = sctp_v6_addr_match_len(daddr, &laddr->a);
+ if (!baddr || (matchlen < bmatchlen)) {
+ baddr = &laddr->a;
+ matchlen = bmatchlen;
+ }
+ }
}
if (baddr) {
diff --git a/net/sctp/outqueue.c b/net/sctp/outqueue.c
index 26dc005..28bccde 100644
--- a/net/sctp/outqueue.c
+++ b/net/sctp/outqueue.c
@@ -744,6 +744,16 @@ static int sctp_outq_flush(struct sctp_outq *q, int rtx_timeout)
*/
list_for_each_entry_safe(chunk, tmp, &q->control_chunk_list, list) {
+ /* RFC 5061, 5.3
+ * F1) This means that until such time as the ASCONF
+ * containing the add is acknowledged, the sender MUST
+ * NOT use the new IP address as a source for ANY SCTP
+ * packet except on carrying an ASCONF Chunk.
+ */
+ if (asoc->src_out_of_asoc_ok &&
+ chunk->chunk_hdr->type != SCTP_CID_ASCONF)
+ continue;
+
list_del_init(&chunk->list);
/* Pick the right transport to use. */
@@ -871,6 +881,9 @@ static int sctp_outq_flush(struct sctp_outq *q, int rtx_timeout)
}
}
+ if (q->asoc->src_out_of_asoc_ok)
+ goto sctp_flush_out;
+
/* Is it OK to send data chunks? */
switch (asoc->state) {
case SCTP_STATE_COOKIE_ECHOED:
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index 152976e..0733273 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -510,7 +510,9 @@ static struct dst_entry *sctp_v4_get_dst(struct sctp_association *asoc,
sctp_v4_dst_saddr(&dst_saddr, dst, htons(bp->port));
rcu_read_lock();
list_for_each_entry_rcu(laddr, &bp->address_list, list) {
- if (!laddr->valid || (laddr->state != SCTP_ADDR_SRC))
+ if (!laddr->valid || (laddr->state == SCTP_ADDR_DEL) ||
+ (laddr->state != SCTP_ADDR_SRC &&
+ !asoc->src_out_of_asoc_ok))
continue;
if (sctp_v4_cmp_addr(&dst_saddr, &laddr->a))
goto out_unlock;
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
index de98665..f341ab2 100644
--- a/net/sctp/sm_make_chunk.c
+++ b/net/sctp/sm_make_chunk.c
@@ -2744,6 +2744,12 @@ struct sctp_chunk *sctp_make_asconf_update_ip(struct sctp_association *asoc,
int addr_param_len = 0;
int totallen = 0;
int i;
+ sctp_addip_param_t del_param; /* 8 Bytes (Type 0xC002, Len and CrrID) */
+ struct sctp_af *del_af;
+ int del_addr_param_len = 0;
+ int del_paramlen = sizeof(sctp_addip_param_t);
+ union sctp_addr_param del_addr_param; /* (v4) 8 Bytes, (v6) 20 Bytes */
+ int del_pickup = 0;
/* Get total length of all the address parameters. */
addr_buf = addrs;
@@ -2756,6 +2762,17 @@ struct sctp_chunk *sctp_make_asconf_update_ip(struct sctp_association *asoc,
totallen += addr_param_len;
addr_buf += af->sockaddr_len;
+ if (asoc->asconf_addr_del_pending && !del_pickup) {
+ if (!sctp_in_scope(asoc->asconf_addr_del_pending,
+ sctp_scope(addr)))
+ continue;
+ /* reuse the parameter length from the same scope one */
+ totallen += paramlen;
+ totallen += addr_param_len;
+ del_pickup = 1;
+ asoc->src_out_of_asoc_ok = 1;
+ SCTP_DEBUG_PRINTK("mkasconf_update_ip: picked same-scope del_pending addr, totallen for all addresses is %d\n", totallen);
+ }
}
/* Create an asconf chunk with the required length. */
@@ -2778,6 +2795,19 @@ struct sctp_chunk *sctp_make_asconf_update_ip(struct sctp_association *asoc,
addr_buf += af->sockaddr_len;
}
+ if (flags == SCTP_PARAM_ADD_IP && del_pickup) {
+ addr = asoc->asconf_addr_del_pending;
+ del_af = sctp_get_af_specific(addr->v4.sin_family);
+ del_addr_param_len = del_af->to_addr_param(addr,
+ &del_addr_param);
+ del_param.param_hdr.type = SCTP_PARAM_DEL_IP;
+ del_param.param_hdr.length = htons(del_paramlen +
+ del_addr_param_len);
+ del_param.crr_id = i;
+
+ sctp_addto_chunk(retval, del_paramlen, &del_param);
+ sctp_addto_chunk(retval, del_addr_param_len, &del_addr_param);
+ }
return retval;
}
@@ -3193,7 +3223,8 @@ static void sctp_asconf_param_success(struct sctp_association *asoc,
local_bh_enable();
list_for_each_entry(transport, &asoc->peer.transport_addr_list,
transports) {
- if (transport->state == SCTP_ACTIVE)
+ if (transport->state == SCTP_ACTIVE &&
+ !asoc->src_out_of_asoc_ok)
continue;
dst_release(transport->dst);
sctp_transport_route(transport, NULL,
@@ -3203,6 +3234,11 @@ static void sctp_asconf_param_success(struct sctp_association *asoc,
case SCTP_PARAM_DEL_IP:
local_bh_disable();
sctp_del_bind_addr(bp, &addr);
+ if (asoc->asconf_addr_del_pending != NULL &&
+ sctp_cmp_addr_exact(asoc->asconf_addr_del_pending, &addr)) {
+ kfree(asoc->asconf_addr_del_pending);
+ asoc->asconf_addr_del_pending = NULL;
+ }
local_bh_enable();
list_for_each_entry(transport, &asoc->peer.transport_addr_list,
transports) {
@@ -3361,6 +3397,9 @@ int sctp_process_asconf_ack(struct sctp_association *asoc,
asconf_len -= length;
}
+ if (no_err && asoc->src_out_of_asoc_ok)
+ asoc->src_out_of_asoc_ok = 0;
+
/* Free the cached last sent asconf chunk. */
list_del_init(&asconf->transmitted_list);
sctp_chunk_free(asconf);
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 3951a10..481293d 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -583,10 +583,6 @@ static int sctp_send_asconf_add_ip(struct sock *sk,
goto out;
}
- retval = sctp_send_asconf(asoc, chunk);
- if (retval)
- goto out;
-
/* Add the new addresses to the bind address list with
* use_as_src set to 0.
*/
@@ -599,6 +595,23 @@ static int sctp_send_asconf_add_ip(struct sock *sk,
SCTP_ADDR_NEW, GFP_ATOMIC);
addr_buf += af->sockaddr_len;
}
+ if (asoc->src_out_of_asoc_ok) {
+ struct sctp_transport *trans;
+
+ list_for_each_entry(trans,
+ &asoc->peer.transport_addr_list, transports) {
+ /* Clear the source and route cache */
+ dst_release(trans->dst);
+ trans->cwnd = min(4*asoc->pathmtu, max_t(__u32,
+ 2*asoc->pathmtu, 4380));
+ trans->ssthresh = asoc->peer.i.a_rwnd;
+ trans->rto = asoc->rto_initial;
+ trans->rtt = trans->srtt = trans->rttvar = 0;
+ sctp_transport_route(trans, NULL,
+ sctp_sk(asoc->base.sk));
+ }
+ }
+ retval = sctp_send_asconf(asoc, chunk);
}
out:
@@ -711,7 +724,9 @@ static int sctp_send_asconf_del_ip(struct sock *sk,
struct sctp_sockaddr_entry *saddr;
int i;
int retval = 0;
+ int stored = 0;
+ chunk = NULL;
if (!sctp_addip_enable)
return retval;
@@ -762,8 +777,32 @@ static int sctp_send_asconf_del_ip(struct sock *sk,
bp = &asoc->base.bind_addr;
laddr = sctp_find_unmatch_addr(bp, (union sctp_addr *)addrs,
addrcnt, sp);
- if (!laddr)
- continue;
+ if ((laddr == NULL) && (addrcnt == 1)) {
+ if (asoc->asconf_addr_del_pending)
+ continue;
+ asoc->asconf_addr_del_pending =
+ kzalloc(sizeof(union sctp_addr), GFP_ATOMIC);
+ asoc->asconf_addr_del_pending->sa.sa_family =
+ addrs->sa_family;
+ asoc->asconf_addr_del_pending->v4.sin_port =
+ htons(bp->port);
+ if (addrs->sa_family == AF_INET) {
+ struct sockaddr_in *sin;
+
+ sin = (struct sockaddr_in *)addrs;
+ asoc->asconf_addr_del_pending->v4.sin_addr.s_addr = sin->sin_addr.s_addr;
+ } else if (addrs->sa_family == AF_INET6) {
+ struct sockaddr_in6 *sin6;
+
+ sin6 = (struct sockaddr_in6 *)addrs;
+ ipv6_addr_copy(&asoc->asconf_addr_del_pending->v6.sin6_addr, &sin6->sin6_addr);
+ }
+ SCTP_DEBUG_PRINTK_IPADDR("send_asconf_del_ip: keep the last address asoc: %p ",
+ " at %p\n", asoc, asoc->asconf_addr_del_pending,
+ asoc->asconf_addr_del_pending);
+ stored = 1;
+ goto skip_mkasconf;
+ }
/* We do not need RCU protection throughout this loop
* because this is done under a socket lock from the
@@ -776,6 +815,7 @@ static int sctp_send_asconf_del_ip(struct sock *sk,
goto out;
}
+skip_mkasconf:
/* Reset use_as_src flag for the addresses in the bind address
* list that are to be deleted.
*/
@@ -801,6 +841,9 @@ static int sctp_send_asconf_del_ip(struct sock *sk,
sctp_sk(asoc->base.sk));
}
+ if (stored)
+ /* We don't need to transmit ASCONF */
+ continue;
retval = sctp_send_asconf(asoc, chunk);
}
out:
^ permalink raw reply related
* Re: [PATCH net-next-2.6 v4 4/5] sctp: Add ASCONF operation on the single-homed host
From: Michio Honda @ 2011-04-25 15:34 UTC (permalink / raw)
To: Wei Yongjun; +Cc: netdev, lksctp-developers
In-Reply-To: <4DB4E04C.70609@cn.fujitsu.com>
I just re-submitted cumulative patches.
About your suggestion to split the patch that reset route at the reception of ASCONF-ACK, I removed those codes.
Because we'd already reset the route just before ASCONF, so not needed after the ASCONF-ACK reception.
I believe the other parts follow all your comments.
I also cleaned up many parts in single-homed host support patch.
Thanks,
- Michio
On Apr 25, 2011, at 11:45 , Wei Yongjun wrote:
>
>> Yes, I think the association cannot be kept, if the single-homed ASCONF receiver moves to the new network before sending ASCONF-ACK.
>> Am I missing?
>
> Oh, yeah, you are right.:-)
>
>> Thanks,
>> - Michio
>>
>> On Apr 25, 2011, at 11:02 , Wei Yongjun wrote:
>>
>>>> Hi,
>>>>
>>>> Such operation would not be supported by specification, in Sec.5.3 in RFC 5061:
>>>> F1) When adding an IP address to an association, the IP address is
>>>> NOT considered fully added to the association until the ASCONF-
>>>> ACK arrives. This means that until such time as the ASCONF
>>>> containing the add is acknowledged, the sender MUST NOT use the
>>>> new IP address as a source for ANY SCTP packet except on
>>>> carrying an ASCONF Chunk.
>>>>
>>>> I think this means we cannot send ASCONF-ACK from the new address even if it bundles ASCONF...
>>> If so, both side do not have valid address to send the such
>>> ASCONF-ACK, and can not recv ASCONF-ACK.
>>>
>>>> - Michio
>>>>
>>>> On Apr 25, 2011, at 9:57 , Wei Yongjun wrote:
>>>>
>>>>>> On Apr 22, 2011, at 13:10 , Wei Yongjun wrote:
>>>>>>
>>>>>>>> Since the sender MUST NOT use the new IP address as a source for ANY SCTP
>>>>>>>> packet except on carrying an ASCONF Chunk. And ASCONF chunk can be bundled.
>>>>>>>> How about this change. If so, you do not need change to sctp_outq_tail();
>>>>>>>>
>>>>>>>> diff --git a/net/sctp/outqueue.c b/net/sctp/outqueue.c
>>>>>>>> index 1c88c89..bd6cc9c 100644
>>>>>>>> --- a/net/sctp/outqueue.c
>>>>>>>> +++ b/net/sctp/outqueue.c
>>>>>>>> @@ -754,6 +754,13 @@ static int sctp_outq_flush(struct sctp_outq *q, int rtx_timeout)
>>>>>>>> */
>>>>>>>>
>>>>>>>> list_for_each_entry_safe(chunk, tmp, &q->control_chunk_list, list) {
>>>>>>>> + /* RFC 5061, 5.3
>>>>>>>> + * F1) This ...
>>>>>>>> + */
>>>>>>>> + if (q->asoc->src_out_of_asoc_ok &&
>>>>>>>> + chunk->chunk_hdr->type != SCTP_CID_ASCONF)
>>>>>>> SCTP_CID_ASCONF_ACK should be also allowed, the peer may
>>>>>>> send ASCONF to do the same thing at the same time.
>>>>>> Sorry for my bad understanding,
>>>>>> Do you mean the situation: "the peer (ASCONF receiver) may send ASCONF-ACK to the unconfirmed destination"?
>>>>>> Or do you mean following situation?
>>>>>> 1. the pear sends ADD/DEL ASCONF to me,
>>>>>> 2. I receive it,
>>>>>> 3. I migrate to the other network and get new address,
>>>>>> 4. I send ASCONF-ACK to the peer from the new address
>>>>> Yes, If both side send ADD/DEL ASCONF to del the last one
>>>>> address at the same time like this:
>>>>>
>>>>> ASCONF ----- ------ASCONF
>>>>> (ADD/DEL) \ / (ADD/DEL)
>>>>> \/
>>>>> /\
>>>>> <----/ \----->
>>>>> ASCONF-ACK---\ /------ASCONF-ACK
>>>>> \/
>>>>> /\
>>>>> <----/ \----->
>>>>>
>>>>> But I do not test for it. Not sure we need to do this, can you
>>>>> check this before commit your new patchset?
>>>>>
>>>>>
>>>>>>>> + continue;
>>>>>>>> +
>>>>>>>> list_del_init(&chunk->list);
>>>>>>>>
>>>>>>>> /* Pick the right transport to use. */
>>>>>>>> @@ -881,6 +888,9 @@ static int sctp_outq_flush(struct sctp_outq *q, int rtx_timeout)
>>>>>>>> }
>>>>>>>> }
>>>>>>>>
>>>>>>>> + if (q->asoc->src_out_of_asoc_ok)
>>>>>>>> + goto sctp_flush_out;
>>>>>>>> +
>>>>>>>> /* Is it OK to send data chunks? */
>>>>>>>> switch (asoc->state) {
>>>>>>>> case SCTP_STATE_COOKIE_ECHOED:
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>> --
>>>>>>> To unsubscribe from this list: send the line "unsubscribe netdev" in
>>>>>>> the body of a message to majordomo@vger.kernel.org
>>>>>>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>>>>>> --
>>>>>> To unsubscribe from this list: send the line "unsubscribe netdev" in
>>>>>> the body of a message to majordomo@vger.kernel.org
>>>>>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>>>>>>
>>>>> --
>>>>> To unsubscribe from this list: send the line "unsubscribe netdev" in
>>>>> the body of a message to majordomo@vger.kernel.org
>>>>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>>
^ permalink raw reply
* Re: Linux TCP's Robustness to Multipath Packet Reordering
From: Eric Dumazet @ 2011-04-25 15:38 UTC (permalink / raw)
To: Dominik Kaspar; +Cc: Carsten Wolff, netdev
In-Reply-To: <BANLkTi=xns1Gdjyt-SX3yDETSQfO23rXXg@mail.gmail.com>
Le lundi 25 avril 2011 à 16:35 +0200, Dominik Kaspar a écrit :
> Hi Eric and Carsten,
>
> Thanks a lot for your quick replies. I don't have a tcpdump of this
> experiment, but here is the tcp_probe log that the plot is based on
> (I'll run a new test using tcpdump if you think that's more useful):
>
> http://home.simula.no/~kaspar/static/mptcp-emu-wlan-hspa-00.log
>
> I have also noticed what Carsten mentions, the tcp_reordering value is
> essential for this whole behavior. When I start an experiment and
> increase sysctl.net.ipv4.tcp_reordering during the running connection,
> the TCP throughput immediately jumps close to the aggregate of both
> paths. Without intervention, as in this experiment, tcp_reordering
> starts out as 3 and then makes small oscillations between 3 and 12 for
> more than 2 minutes. At about second 141, TCP somehow finds a new
> highest reordering value (23) and at the same time, the throughput
> jumps up "to the next level". The value of 23 is then used all the way
> until second 603, when the reordering value becomes 32 and the
> throughput again jumps up a level.
>
> I understand that tp->reordering is increased when reordering is
> detected, but what causes tp->reordering to sometimes be decreased
> back to 3? Also, why does a decrease back to 3 not make the whole
> procedure start all over again? For example, at second 1013.64,
> tp->reordering falls from 127 down to 3. A second later (1014.93) it
> then suddenly increases from 3 up to 32 without considering any
> numbers in between. Why it is now suddenly so fast? At the very
> beginning, it took 600 seconds to grow from 3 to 32 and afterward it
> just takes a second...?
>
> For the experiments, all default TCP options were used, meaning that
> SACK, DSACK, Timestamps, were all enabled. Not sure how to turn on/off
> TSO... so that is probably enabled, too. Path emulation is done with
> tc/netem at the receiver interfaces (eth1, eth2) with this script:
>
Since you have at sender a rule to spoof destination address of packets,
you should make sure you dont send "super packets (up to 64Kbytes)",
because it would stress the multipath more than you wanted to. This way,
you send only normal packets (1500 MTU).
ethtool -K eth0 tso off
ethtool -K eth0 gso off
I am pretty sure it should help your (atypic) workload.
> http://home.simula.no/~kaspar/static/netem.sh
>
> Greetings,
> Dominik
^ permalink raw reply
* ar9280+802.11na+ath9k+kismet don't capture data packets
From: Антон @ 2011-04-25 17:54 UTC (permalink / raw)
To: netdev
Hello!
The platform uses D-link DIR-825 Atheros AR7161, with two AR9280(802.11bgn and 802.11an)
kismet-2010-07-R1 is installed to OpenWrt Backfire Trunk. Used driver ath9k of compat-wireless-2011-04-19.
For tests I use D-Link Dir-825 AP and D-Link DWA-160. Connection speed is 300 Mbps at 36 channel.
Kismet captures PHY and Control packets, and don't capture the data packets.
/etc/config/wireless
config wifi-device radio0
option type mac80211
option channel 11
option macaddr 00:18:e7:ec:b0:5f
option hwmode 11ng
option hwmode_11n g
option htmode HT40+
list ht_capab HT40-
list ht_capab HT40+
list ht_capab HT20
config wifi-iface
option device radio0
option mode monitor
config wifi-device radio1
option type mac80211
option channel 36
option macaddr 00:18:e7:ec:b0:60
option hwmode 11na
option hwmode_11n a
option htmode HT40+
list ht_capab HT40-
list ht_capab HT40+
list ht_capab HT20
config wifi-iface
option device radio1
option mode monitor
device wlan0 entered promiscuous mode
device wlan1 entered promiscuous mode
iwconfig
wlan0 IEEE 802.11bgn Mode:Monitor Tx-Power=27 dBm
RTS thr:off Fragment thr:off
Power Management:on
wlan1 IEEE 802.11an Mode:Monitor Tx-Power=17 dBm
RTS thr:off Fragment thr:off
Power Management:on
Transferred to file 600 Mb
After that ifconfig issued:
ifconfig
wlan0 Link encap:UNSPEC HWaddr 00-18-E7-EC-B0-5F-00-47-00-00-00-00-00-00-0
UP BROADCAST RUNNING PROMISC MULTICAST MTU:1500 Metric:1
RX packets:9865 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3043414 (2.9 MiB) TX bytes:0 (0.0 B)
wlan1 Link encap:UNSPEC HWaddr 00-18-E7-EC-B0-60-00-47-00-00-00-00-00-00-0
UP BROADCAST RUNNING PROMISC MULTICAST MTU:1500 Metric:1
RX packets:365275 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:20117793 (19.1 MiB) TX bytes:0 (0.0 B)
Sniffing result:
MAC Src MAC Dst Channel Signal Type Crypt Packets SSID
00:18:E7:FD:8E:D8 00:19:5B:7E:09:CE 6 -42 AP WEP 7629 q183
00:18:E7:FD:8E:DA F0:7D:68:71:40:DC 36 -60 AP TKIP WPA PSK... 1703 q183-media
1C:65:9D:21:27:8F 00:18:E7:FD:8E:D8 6 -65 AP WEP 2607 q183
00:00:00:00:00:00 00:18:E7:FD:8E:D8 - -65 AP - 370415 -
00:19:5B:7E:09:CE 00:18:E7:FD:8E:D8 - -67 Probe WEP 124 q183
F0:7D:68:71:40:DC 00:18:E7:FD:8E:DA - -39 AP TKIP WPA PSK... 41 q183-media
Captures the driver ath9k data packets in the mode 802.11na? Can be said about this with 100% certainty? Checked it?
^ permalink raw reply
* Re: [PATCH 2/9] net-ethtool: Convert (hw_/vlan_/wanted_)features fields from u32 type to u64.
From: Mahesh Bandewar @ 2011-04-25 18:14 UTC (permalink / raw)
To: Ben Hutchings; +Cc: David Miller, netdev, Michał Mirosław
In-Reply-To: <1303623041.3032.97.camel@localhost>
On Sat, Apr 23, 2011 at 10:30 PM, Ben Hutchings
<bhutchings@solarflare.com> wrote:
> On Fri, 2011-04-22 at 16:36 -0700, Mahesh Bandewar wrote:
>> Signed-off-by: Mahesh Bandewar <maheshb@google.com>
>> ---
>> include/linux/ethtool.h | 26 +++++++------
>> net/core/ethtool.c | 89 ++++++++++++++++------------------------------
>> 2 files changed, 45 insertions(+), 70 deletions(-)
>>
>> diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
>> index 9de3127..71e8a02 100644
>> --- a/include/linux/ethtool.h
>> +++ b/include/linux/ethtool.h
>> @@ -605,10 +605,10 @@ struct ethtool_flash {
>> * @never_changed: mask of features not changeable for any device
>> */
>> struct ethtool_get_features_block {
>> - __u32 available;
>> - __u32 requested;
>> - __u32 active;
>> - __u32 never_changed;
>> + __u64 available;
>> + __u64 requested;
>> + __u64 active;
>> + __u64 never_changed;
>> };
>>
>> /**
>> @@ -618,10 +618,11 @@ struct ethtool_get_features_block {
>> * out: number of elements in features[] needed to hold all features
>> * @features: state of features
>> */
>> +/* TODO Why is this needed XXX */
>
> Precisely to allow for expansion to more than 32 bits.
>
:) That comment was not supposed to be part of the patch and was just
to aid my thinking while we were discussing about the approach to
extend features. (I thought) if we have decided not to use use arrays,
then why to complicate this interface, so was attempting to simplify
the interface.
>> struct ethtool_gfeatures {
>> __u32 cmd;
>> __u32 size;
>> - struct ethtool_get_features_block features[0];
>> + struct ethtool_get_features_block features;
>> };
>>
>> /**
>> @@ -630,8 +631,8 @@ struct ethtool_gfeatures {
>> * @requested: values of features to be changed
>> */
>> struct ethtool_set_features_block {
>> - __u32 valid;
>> - __u32 requested;
>> + __u64 valid;
>> + __u64 requested;
>> };
>>
>> /**
>> @@ -640,10 +641,11 @@ struct ethtool_set_features_block {
>> * @size: array size of the features[] array
>> * @features: feature change masks
>> */
>> +/* TODO Why is this needed XXX */
>> struct ethtool_sfeatures {
>> __u32 cmd;
>> __u32 size;
>> - struct ethtool_set_features_block features[0];
>> + struct ethtool_set_features_block features;
>> };
> [...]
>
> These structures are part of the userland API, but they are new in
> 2.6.39. So they can still be changed up until 2.6.39 is released, but
> not afterwards.
>
got it!
> If we think 64 bits will be enough for the next 10 years, then let's
> just go with a single 64-bit feature word. If we're not so sure then
> then the ethtool API should continue to allow for multiple words
> (whether 32-bit or 64-bit).
>
I think even 64 bits may not be enough, so in the earlier thread I had
mentioned that, this would (probably) give us next two years! I didn't
know this constraint though.
--mahesh..
> Ben.
>
> --
> Ben Hutchings, Senior Software Engineer, Solarflare
> Not speaking for my employer; that's the marketing department's job.
> They asked us to note that Solarflare product names are trademarked.
>
>
^ permalink raw reply
* Re: [PATCHv5] usbnet: Resubmit interrupt URB once if halted
From: Paul Stewart @ 2011-04-25 18:41 UTC (permalink / raw)
To: Oliver Neukum
Cc: Alan Stern, netdev-u79uwXL29TY76Z2rM5mHXA,
linux-usb-u79uwXL29TY76Z2rM5mHXA, davem-fT/PcQaiUtIeIZ0/mPfg9Q,
bhutchings-s/n/eUQHGBpZroRs9YW3xA
In-Reply-To: <201104240836.47491.oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org>
On Sat, Apr 23, 2011 at 11:36 PM, Oliver Neukum <oliver-GvhC2dPhHPQdnm+yROfE0A@public.gmane.org> wrote:
> Am Freitag, 22. April 2011, 17:59:15 schrieb Paul Stewart:
>> >
>> >> free_netdev(net);
>> >> usb_put_dev (xdev);
>> >> }
>> >> @@ -1285,6 +1291,10 @@ int usbnet_suspend (struct usb_interface *intf, pm_message_t message)
>> >> * wake the device
>> >> */
>> >> netif_device_attach (dev->net);
>> >> +
>> >> + /* Stop interrupt URBs */
>> >> + if (dev->interrupt)
>> >> + usb_kill_urb(dev->interrupt);
>> >> }
>> >> return 0;
>> >> }
>> >
>> > There is a subtle question here: When is the best time to kill the
>> > interrupt URB? Without knowing any of the details, I'd guess that the
>> > interrupt URB reports asynchronous events and the driver could run into
>> > trouble if one of those events occurred while everything else was
>> > turned off. This suggests that the interrupt URB should be killed as
>> > soon as possible rather than as late as possible. But maybe it doesn't
>> > matter; it all depends on the design of the driver.
>>
>> I'm not sure I can answer this question either. As it stands, nobody
>> was killing them before. Just trying to make it better.
>
> Hm. Are we looking at the same code?
Perhaps not. I'm working out of the netdev-2.6 git repository. Is
this the wrong place?
> usbnet_suspend now has:
>
> /*
> * accelerate emptying of the rx and queues, to avoid
> * having everything error out.
> */
> netif_device_detach (dev->net);
> usbnet_terminate_urbs(dev);
> usb_kill_urb(dev->interrupt);
>
> This suggests that if you want to resubmit the interrupt URB in resume()
> you do it first. Which drivers use the interrupt URB?
The asix driver uses it fo signal link status.
>
> Regards
> Oliver
>
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: Oops in 2.6.39 include/net/dst.h: dst_metrics_write_ptr() running l2tp over ipsec
From: David Miller @ 2011-04-25 18:54 UTC (permalink / raw)
To: berny156; +Cc: eric.dumazet, linux-kernel, netdev
In-Reply-To: <4DB54450.90806@gmx.de>
From: Held Bernhard <berny156@gmx.de>
Date: Mon, 25 Apr 2011 11:52:16 +0200
> Am 25.04.2011 10:07, schrieb Eric Dumazet:
>> From: Held Bernhard<berny156@gmx.de>
...
>> Thanks for your report and patch.
>>
>> Maybe following patch is the way to fix this, please test it.
>>
>>
>> [PATCH] net: provide cow_metrics() methods to blackhole dst_ops
...
>> The oops happens in dst_metrics_write_ptr()
>> include/net/dst.h:124: return dst->ops->cow_metrics(dst, p);
>>
>> dst->ops->cow_metrics is NULL and causes the oops.
>>
>> Provide cow_metrics() methods, like we did in commit 214f45c91bb
>> (net: provide default_advmss() methods to blackhole dst_ops)
>>
>> Signed-off-by: Held Bernhard<berny156@gmx.de>
>> Signed-off-by: Eric Dumazet<eric.dumazet@gmail.com>
...
> Your patch works flawlessly.
>
> Thanks for the quick response!
Applied, thanks everyone.
^ permalink raw reply
* Re: [PATCH] net: make WARN_ON in dev_disable_lro() useful
From: David Miller @ 2011-04-25 18:56 UTC (permalink / raw)
To: eric.dumazet; +Cc: mirq-linux, netdev
In-Reply-To: <1303449113.13893.2.camel@edumazet-laptop>
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Fri, 22 Apr 2011 07:11:53 +0200
> Le vendredi 22 avril 2011 à 00:42 +0200, Michał Mirosław a écrit :
>> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
>> ---
>> net/core/dev.c | 3 ++-
>> 1 files changed, 2 insertions(+), 1 deletions(-)
>>
>> diff --git a/net/core/dev.c b/net/core/dev.c
>> index 3871bf6..3421184 100644
>> --- a/net/core/dev.c
>> +++ b/net/core/dev.c
>> @@ -1315,7 +1315,8 @@ void dev_disable_lro(struct net_device *dev)
>> return;
>>
>> __ethtool_set_flags(dev, flags & ~ETH_FLAG_LRO);
>> - WARN_ON(dev->features & NETIF_F_LRO);
>> + if (unlikely(dev->features & NETIF_F_LRO))
>> + netdev_WARN(dev, "failed to disable LRO!\n");
>> }
>> EXPORT_SYMBOL(dev_disable_lro);
>>
>
> Yes, as suggested one month ago
> http://permalink.gmane.org/gmane.linux.network/189951
>
> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Applied, thanks.
^ permalink raw reply
* Re: [patch net-next-2.6] bonding: move processing of recv handlers into handle_frame()
From: David Miller @ 2011-04-25 19:00 UTC (permalink / raw)
To: jpirko
Cc: netdev, shemminger, kaber, fubar, eric.dumazet, nicolas.2p.debian,
andy
In-Reply-To: <1303220896-9092-1-git-send-email-jpirko@redhat.com>
From: Jiri Pirko <jpirko@redhat.com>
Date: Tue, 19 Apr 2011 15:48:16 +0200
> Since now when bonding uses rx_handler, all traffic going into bond
> device goes thru bond_handle_frame. So there's no need to go back into
> bonding code later via ptype handlers. This patch converts
> original ptype handlers into "bonding receive probes". These functions
> are called from bond_handle_frame and they are registered per-mode.
>
> Note that vlan packets are also handled because they are always untagged
> thanks to vlan_untag()
>
> Note that this also allows arpmon for eth-bond-bridge-vlan topology.
>
> Signed-off-by: Jiri Pirko <jpirko@redhat.com>
Applied, thanks.
^ permalink raw reply
* Re: [PATCH net-next-2.6] be2net: Fixed a bug in be_cmd_get_regs().
From: David Miller @ 2011-04-25 19:14 UTC (permalink / raw)
To: somnath.kotur; +Cc: netdev
In-Reply-To: <8a31447a-9317-4569-ae2b-865feb9ce594@exht1.ad.emulex.com>
From: Somnath Kotur <somnath.kotur@emulex.com>
Date: Thu, 21 Apr 2011 18:48:12 +0530
> Resending patch as the 'changelog' got missed out in my previous submission.
>
> Same WRB entry was being reused over different iterations of a
> loop while issuing non-embedded IOCTL requests.Fixed couple of minor bugs
> in this path as well.
> Re-factored code to alloc/free memory for DMA outside of loop
>
>
> Signed-off-by: Somnath Kotur <somnath.kotur@emulex.com>
Applied, thanks.
^ permalink raw reply
* pull request: wireless-next-2.6 2011-04-25
From: John W. Linville @ 2011-04-25 19:30 UTC (permalink / raw)
To: davem; +Cc: linux-wireless, netdev
Dave,
Here is another big batch of updates intended for 2.6.40...
There is the usual huge batch of changes for ath9k, and iwlagn, a bunch
for ath9k_htc, rt2x00, and ath5k, a few more for mwifiex, and a handful
of others. Also included is a big batch of Bluetooth updates as well.
Please let me know if there are problems!
Thanks,
John
---
The following changes since commit b71d1d426d263b0b6cb5760322efebbfc89d4463:
inet: constify ip headers and in6_addr (2011-04-22 11:04:14 -0700)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-next-2.6.git for-davem
Amitkumar Karwar (4):
mwifiex: cleanup ioctl wait queue and abstraction layer
mwifiex: remove unused function parameters
mwifiex: remove some macro definitions
mwifiex: optimize driver initialization code
Antonio Ospite (1):
rfkill: Regulator consumer driver for rfkill
Bing Zhao (2):
mwifiex: fix cmd_skb headroom decreasing issue
mwifiex: rename function mwifiex_is_ba_stream_avail
Brian Cavagnolo (1):
mwl8k: use traffic threshold to decide when to start ampdu
Chaoming Li (1):
rtlwifi: rtl8192ce: Fix LED initialization
Felix Fietkau (23):
ath9k: fix PS-Poll reception on AR9160 and earlier
ath9k: fix too early enabling of rx during ath_startrecv()
ath9k_hw: remove unnecessary parts of the AR9380 SREV check
ath5k: fix tx status reporting issues
ath5k: fix short preamble rate duration value
ath5k: fix SIFS time handling
ath5k: fix slot time handling
ath5k: optimize tx descriptor setup
ath5k: remove ts_rate from ath5k_tx_status
ath5k: optimize tx status processing
ath5k: optimize rx status processing
ath5k: remove ts_retry from ath5k_tx_status
ath5k: clean up debugfs code
ath5k: reduce interrupt load caused by rx/tx interrupts
mac80211: receive EAP frames from a station in an AP VLAN on the main AP
ath5k: disable 5 GHz support if a 2.4 GHz radio is detected
ath: unshare struct ath_bus_ops between ath5k and ath9k
ath5k: add a new bus op for reading the mac address
ath5k: fix the EEPROM check for hw AES crypto support
ath5k: disable 5 GHz support for the dualband PHY chip on dual-radio AR5312
mac80211: add a function for setting the TIM bit for a specific station
ath9k: fix powersave frame filtering/buffering in AP mode
ath9k: assign keycache slots to unencrypted stations
Gabor Juhos (1):
ath9k: introduce ATH9K_{PCI,AHB} config options
Garen Tamrazian (1):
iwlagn: fix radar frame rejection
Gertjan van Wingerde (6):
rt2x00: Linksys WUSB600N rev2 is a RT3572 device.
rt2x00: Allow dynamic addition of PCI/USB IDs.
rt2x00: Add USB IDs.
rt2x00: RT33xx device support is no longer experimental.
rt2x00: Enable support for RT53xx PCI devices by default.
rt2x00: Merge rt2x00ht.c contents in other files.
Gustavo F. Padovan (26):
Bluetooth: Create struct l2cap_chan
Bluetooth: Use struct list_head for L2CAP channels list
Bluetooth: Remove struct del_list
Bluetooth: Move ident to struct l2cap_chan
Bluetooth: Move conf_{req,rsp} stuff to struct l2cap_chan
Bluetooth: clean up l2cap_sock_recvmsg()
Bluetooth: Move conn_state to struct l2cap_chan
Bluetooth: Move of ERTM *_seq vars to struct l2cap_chan
Bluetooth: Move more ERTM stuff to struct l2cap_chan
Bluetooth: Move SDU related vars to struct l2cap_chan
Bluetooth: Move remote info to struct l2cap_chan
Bluetooth: Move ERTM timers to struct l2cap_chan
Bluetooth: Move srej and busy queues to struct l2cap_chan
Bluetooth: Move busy workqueue to struct l2cap_chan
Bluetooth: Fix lockdep warning with skb list lock
Bluetooth: Move SREJ list to struct l2cap_chan
Bluetooth: Remove some sk references from l2cap_core.c
Bluetooth: Remove unneeded uninitialized_vars()
Bluetooth: Move tx queue to struct l2cap_chan
Bluetooth: Fix wrong comparison in listen()
Bluetooth: Clean up ath3k_load_firmware()
Bluetooth: Add proper handling of received LE data
Bluetooth: Check return value of hci_recv_stream_fragment()
Bluetooth: Don't lock sock inside l2cap_get_sock_by_scid()
Bluetooth: Fix another locking unbalance
Bluetooth: Fix lockdep warning in L2CAP
Helmut Schaa (7):
rt2x00: Fix stuck queue in tx failure case
rt2x00: Make rt2x00_queue_entry_for_each more flexible
rt2x00: Use correct TBTT_SYNC config in AP mode
rt2x00: Update TX_SW_CFG2 init value
rt2x00: Use TXOP_HTTXOP for beacons
rt2x00: Always inline rt2x00pci_enable_interrupt
rt2x00: Optimize register access in rt2800pci
Ivo van Doorn (5):
rt2x00: Split rt2x00dev->flags
rt2x00: Decrease association time for USB devices
rt2x00: Optimize register access in rt2800usb
rt2x00: Implement get_ringparam callback function
rt2x00: Implement get_antenna and set_antenna callback functions
Javier Cardona (9):
nl80211: rename NL80211_MESH_SETUP_VENDOR_PATH_SEL_IE
cfg80211/nl80211: Add userspace authentication flag to mesh setup
mac80211: ignore peers if security is enabled for this mesh
nl80211/mac80211: let userspace authenticate stations
mac80211: Let user space receive and send mesh auth/deauth frames
mac80211: ignore peer link requests from unauthenticated stations.
nl80211/mac80211: Perform PLINK_ACTION on new station
nl80211: New notification to discover mesh peer candidates.
mac80211: send notification on new peer candidate for our secure mesh
Jiejing Zhang (1):
Bluetooth: hci_uart: check the return value of recv()
Johannes Berg (7):
iwlwifi: fix bugs in change_interface
iwlagn: clean up & autodetect statistics
iwlagn: downgrade warning on unknown TLV
iwlagn: remove most BUG_ON instances
iwlagn: verify that huge commands are synchronous
iwlagn: use huge command for beacon
mac80211: explain padding in place of rate field
Johannes Stezenbach (4):
rt2800usb: read TX_STA_FIFO asynchronously
rt2x00: fix queue timeout checks
rt2800usb: handle TX status timeouts
rt2800usb: add timer to handle TX_STA_FIFO
John W. Linville (6):
ath5k: improve pcal error handling for ENOMEM case
ath5k: improve comments for optimized tx descriptor setup
ath9k: avoid using trinary operator w/ TX_STAT_INC
Merge branch 'wireless-next-2.6' of git://git.kernel.org/.../iwlwifi/iwlwifi-2.6
Merge branch 'master' of git://git.kernel.org/.../padovan/bluetooth-next-2.6
Merge branch 'master' of git://git.kernel.org/.../linville/wireless-next-2.6 into for-davem
Kevin Gan (1):
Bluetooth: btmrvl: support Marvell Bluetooth device SD8787
Larry Finger (1):
rtlwifi: Fix unitialized variable warnings
Layne Edwards (1):
rt2x00: Enable WLAN LED on Ralink SoC (rt305x) devices
Luis R. Rodriguez (1):
ath: fix 0x6C for beaconing/passive scan flags based on country IE
Mark Davis (1):
rt2800usb: Add seven new USB IDs
Mohammed Shafi Shajakhan (1):
{mac|nl}80211: Add station connected time
Nishant Sarmukadam (1):
mwl8k: interrupt handling changes
Paul Bolle (1):
iwl4965: drop a lone pr_err()
Rajkumar Manoharan (10):
ath9k_hw: Fix instable target power control b/w CCK/OFDM
ath9k: Fix kernel panic on module unload
ath9k_hw: Remove unused code in AR9287 eeprom
ath9k_hw: update Ar9003 intervals to fix carrier leak
ath9k_hw: update AR9003 low_ob_db_tx_gain to improve spur performance
ath9k: Fix improper beacon slot selection in IBSS
ath9k_htc: Add debugfs support to change debug mask
ath9k_htc: Cleanup HTC debugfs
ath9k_htc: Fix free slot value for cab queue
ath9k: Fix beacon generation on foreign channel
Randy Dunlap (1):
mac80211: fix debugfs printk format warning
Senthil Balasubramanian (3):
ath9k: Add RSSI information from control and extension chains
ath9k: Update gain table for AR9485
ath: Add a missing world regulatory domain 0x6C
Sergei Shtylyov (1):
iwlegacy: use pci_dev->revision
Sujith Manoharan (40):
ath9k_htc: Remove AR7010 v1.0 support
ath9k_htc: Rename firmware
ath9k_htc: Add a WMI command to get the firmware version
ath9k_htc: Fix WMI and beacon header
ath9k_htc: Add beacon slots
ath9k_htc: Add TSF adjust capability
ath9k_htc: Configure the beacon queue
ath9k_htc: Handle buffered frames in AP mode
ath9k_htc: Fix beacon miss under heavy load
ath9k_htc: Queue WMI events
ath9k_htc: Move debug code to a separate file
ath9k_htc: Add RX error statistics
ath9k_htc: Fix RX length check
ath9k_htc: Remove unused WMI commands
ath9k_htc: Use SKB's private area for TX parameters
ath9k_htc: Sync struct ath9k_htc_target_sta with FW
ath9k_htc: Sync struct ath9k_htc_target_vif with FW
ath9k_htc: Sync struct ath9k_htc_cap_target with FW
ath9k_htc: Remove unused WMI_WLAN_TXCOMP_EVENTID
ath9k_htc: Move TX specific stuff to a separate structure
ath9k_htc: Reduce TX queue size
ath9k_htc: Sync MGMT/DATA packet headers with firmware
ath9k_htc: Add a new WMI event WMI_TXSTATUS_EVENTID
ath9k_htc: Increase URB count for REG_IN pipe
ath9k_htc: Fix TX queue management
ath9k_htc: Introduce new HTC API
ath9k_htc: Move endpoint header parsing to TX tasklet
ath9k_htc: Add TX slots
ath9k_htc: Use helper functions for TX processing
ath9k_htc: Drain pending TX frames properly
ath9k_htc: Optimize HTC start/stop API
ath9k_htc: Drain packets on station removal
ath9k_htc: Add support for TX completion
ath9k_htc: Add a debugfs file to dump TX slot information
ath9k_htc: Add a debugfs file showing endpoint status
ath9k_htc: Add a timer to cleanup WMI events
ath9k_htc: Use separate URB pool for management frames
ath9k_htc: Use helper routines for transmission
ath9k_htc: Add detailed firmware statistics
ath9k_htc: Enable AP and P2P modes
Szymon Janc (1):
Bluetooth: Fix Out Of Band pairing when mgmt interface is disabled
Vasanthakumar Thiagarajan (2):
ath9k: Implement integer mode for AR9485
ath9k: Register id table for platform device
Vivek Natarajan (2):
mac80211: Check for queued frames before entering power save.
ath9k: Implement dev_tx_frames_pending callback.
Wey-Yi Guy (18):
iwlagn: remove un-necessary function pointer
iwlagn: PAPD read for 2000 series devices
iwlagn: no 3945 define needed
iwlagn: remove unused 3945 define
iwlagn: cleanup to remove the reference for 3945
iwlagn: remove more reference to legacy devices
iwlagn: remove un-needed configuration
iwlagn: more cleanup to remove unused reference
iwlagn: all _agn devices support power save mode
iwlagn: tx power calib always done in firmware
iwlagn: sensitivity and chain noise done by driver
iwlagn: use direct call for led functions
iwlagn: always support uCode trace
iwlagn: temperature should be measure for all _agn devices
iwlagn: no 5.2GHz/HT40 support for bgn devices
iwlagn: remove un-necessary ieee80211_ops
iwlagn: remove legacy ops
iwlagn: remove led_ops
Yogesh Ashok Powar (4):
mwifiex: use common keyinfo bitmap for different key types
mwl8k: Fix checkpatch.pl and sparse warnings and errors
mwifiex: remove redundant "return" at end of void function
mwifiex: remove redundant local variables and comments
cozybit Inc (1):
mac80211: Allocate new mesh path and portal tables before taking locks
roel (2):
ath9k_hw: index out of bounds
ath9k: index out of bounds
root (1):
iwlwifi: remove extranious macro from firmware define
drivers/bluetooth/Kconfig | 4 +-
drivers/bluetooth/ath3k.c | 3 -
drivers/bluetooth/btmrvl_sdio.c | 124 ++-
drivers/bluetooth/btmrvl_sdio.h | 68 +-
drivers/bluetooth/hci_ath.c | 7 +-
drivers/bluetooth/hci_h4.c | 7 +-
drivers/bluetooth/hci_ldisc.c | 6 +-
drivers/net/wireless/ath/ath.h | 9 +-
drivers/net/wireless/ath/ath5k/ahb.c | 28 +
drivers/net/wireless/ath/ath5k/ath5k.h | 31 +-
drivers/net/wireless/ath/ath5k/attach.c | 7 +-
drivers/net/wireless/ath/ath5k/base.c | 71 +-
drivers/net/wireless/ath/ath5k/base.h | 7 +-
drivers/net/wireless/ath/ath5k/caps.c | 3 +
drivers/net/wireless/ath/ath5k/debug.c | 65 +-
drivers/net/wireless/ath/ath5k/debug.h | 17 -
drivers/net/wireless/ath/ath5k/desc.c | 158 +--
drivers/net/wireless/ath/ath5k/eeprom.c | 158 +--
drivers/net/wireless/ath/ath5k/mac80211-ops.c | 9 +
drivers/net/wireless/ath/ath5k/pci.c | 32 +
drivers/net/wireless/ath/ath5k/pcu.c | 35 +-
drivers/net/wireless/ath/ath5k/qcu.c | 4 +-
drivers/net/wireless/ath/ath9k/Kconfig | 21 +-
drivers/net/wireless/ath/ath9k/Makefile | 6 +-
drivers/net/wireless/ath/ath9k/ahb.c | 14 +-
drivers/net/wireless/ath/ath9k/ar9002_mac.c | 12 +-
drivers/net/wireless/ath/ath9k/ar9002_phy.h | 6 +
.../net/wireless/ath/ath9k/ar9003_2p2_initvals.h | 178 ++--
drivers/net/wireless/ath/ath9k/ar9003_mac.c | 12 +-
drivers/net/wireless/ath/ath9k/ar9003_phy.c | 17 +-
drivers/net/wireless/ath/ath9k/ar9485_initvals.h | 10 +-
drivers/net/wireless/ath/ath9k/ath9k.h | 12 +-
drivers/net/wireless/ath/ath9k/beacon.c | 44 +-
drivers/net/wireless/ath/ath9k/debug.c | 40 +-
drivers/net/wireless/ath/ath9k/debug.h | 7 +
drivers/net/wireless/ath/ath9k/eeprom.h | 6 +-
drivers/net/wireless/ath/ath9k/eeprom_4k.c | 26 +
drivers/net/wireless/ath/ath9k/eeprom_9287.c | 25 +-
drivers/net/wireless/ath/ath9k/hif_usb.c | 334 ++++--
drivers/net/wireless/ath/ath9k/hif_usb.h | 7 +-
drivers/net/wireless/ath/ath9k/htc.h | 211 ++-
drivers/net/wireless/ath/ath9k/htc_drv_beacon.c | 318 ++++-
drivers/net/wireless/ath/ath9k/htc_drv_debug.c | 505 ++++++++
drivers/net/wireless/ath/ath9k/htc_drv_gpio.c | 12 +-
drivers/net/wireless/ath/ath9k/htc_drv_init.c | 91 +-
drivers/net/wireless/ath/ath9k/htc_drv_main.c | 322 ++----
drivers/net/wireless/ath/ath9k/htc_drv_txrx.c | 790 +++++++++---
drivers/net/wireless/ath/ath9k/htc_hst.c | 50 +-
drivers/net/wireless/ath/ath9k/htc_hst.h | 14 +-
drivers/net/wireless/ath/ath9k/hw-ops.h | 5 +
drivers/net/wireless/ath/ath9k/hw.c | 45 +-
drivers/net/wireless/ath/ath9k/hw.h | 9 +
drivers/net/wireless/ath/ath9k/mac.h | 1 -
drivers/net/wireless/ath/ath9k/main.c | 63 +
drivers/net/wireless/ath/ath9k/phy.h | 1 -
drivers/net/wireless/ath/ath9k/rc.c | 3 +-
drivers/net/wireless/ath/ath9k/recv.c | 6 +-
drivers/net/wireless/ath/ath9k/reg.h | 35 +-
drivers/net/wireless/ath/ath9k/wmi.c | 122 ++-
drivers/net/wireless/ath/ath9k/wmi.h | 80 +-
drivers/net/wireless/ath/ath9k/xmit.c | 111 ++-
drivers/net/wireless/ath/key.c | 6 +-
drivers/net/wireless/ath/regd.c | 8 +-
drivers/net/wireless/ath/regd_common.h | 2 +
drivers/net/wireless/iwlegacy/iwl-4965-rs.c | 1 -
drivers/net/wireless/iwlegacy/iwl4965-base.c | 2 +-
drivers/net/wireless/iwlwifi/Makefile | 2 +-
drivers/net/wireless/iwlwifi/iwl-1000.c | 24 +-
drivers/net/wireless/iwlwifi/iwl-2000.c | 43 +-
drivers/net/wireless/iwlwifi/iwl-5000.c | 34 +-
drivers/net/wireless/iwlwifi/iwl-6000.c | 52 +-
drivers/net/wireless/iwlwifi/iwl-agn-calib.c | 43 +-
drivers/net/wireless/iwlwifi/iwl-agn-calib.h | 4 +-
drivers/net/wireless/iwlwifi/iwl-agn-debugfs.c | 134 +--
drivers/net/wireless/iwlwifi/iwl-agn-led.c | 73 --
drivers/net/wireless/iwlwifi/iwl-agn-led.h | 33 -
drivers/net/wireless/iwlwifi/iwl-agn-lib.c | 39 +-
drivers/net/wireless/iwlwifi/iwl-agn-rs.h | 1 -
drivers/net/wireless/iwlwifi/iwl-agn-rxon.c | 13 +
drivers/net/wireless/iwlwifi/iwl-agn-ucode.c | 3 +
drivers/net/wireless/iwlwifi/iwl-agn.c | 66 +-
drivers/net/wireless/iwlwifi/iwl-agn.h | 3 +-
drivers/net/wireless/iwlwifi/iwl-commands.h | 64 -
drivers/net/wireless/iwlwifi/iwl-core.c | 71 +-
drivers/net/wireless/iwlwifi/iwl-core.h | 56 +-
drivers/net/wireless/iwlwifi/iwl-debugfs.c | 53 +-
drivers/net/wireless/iwlwifi/iwl-dev.h | 44 +-
drivers/net/wireless/iwlwifi/iwl-eeprom.c | 6 -
drivers/net/wireless/iwlwifi/iwl-eeprom.h | 1 -
drivers/net/wireless/iwlwifi/iwl-fh.h | 38 +-
drivers/net/wireless/iwlwifi/iwl-hcmd.c | 12 +-
drivers/net/wireless/iwlwifi/iwl-helpers.h | 13 +
drivers/net/wireless/iwlwifi/iwl-led.c | 30 +-
drivers/net/wireless/iwlwifi/iwl-led.h | 1 +
drivers/net/wireless/iwlwifi/iwl-power.c | 17 +-
drivers/net/wireless/iwlwifi/iwl-prph.h | 16 +-
drivers/net/wireless/iwlwifi/iwl-rx.c | 319 +++---
drivers/net/wireless/iwlwifi/iwl-sta.c | 9 +-
drivers/net/wireless/iwlwifi/iwl-tx.c | 39 +-
drivers/net/wireless/mwifiex/11n.c | 34 +-
drivers/net/wireless/mwifiex/11n.h | 53 +-
drivers/net/wireless/mwifiex/11n_aggr.c | 5 +-
drivers/net/wireless/mwifiex/11n_rxreorder.c | 36 +-
drivers/net/wireless/mwifiex/11n_rxreorder.h | 6 +-
drivers/net/wireless/mwifiex/README | 2 +-
drivers/net/wireless/mwifiex/cfg80211.c | 224 ++---
drivers/net/wireless/mwifiex/cfp.c | 17 +-
drivers/net/wireless/mwifiex/cmdevt.c | 194 ++--
drivers/net/wireless/mwifiex/debugfs.c | 7 +-
drivers/net/wireless/mwifiex/decl.h | 38 +-
drivers/net/wireless/mwifiex/fw.h | 29 +-
drivers/net/wireless/mwifiex/init.c | 14 +-
drivers/net/wireless/mwifiex/ioctl.h | 3 +-
drivers/net/wireless/mwifiex/join.c | 128 +--
drivers/net/wireless/mwifiex/main.c | 174 +--
drivers/net/wireless/mwifiex/main.h | 142 +--
drivers/net/wireless/mwifiex/scan.c | 154 +--
drivers/net/wireless/mwifiex/sdio.c | 49 +-
drivers/net/wireless/mwifiex/sta_cmd.c | 127 +-
drivers/net/wireless/mwifiex/sta_cmdresp.c | 47 +-
drivers/net/wireless/mwifiex/sta_event.c | 25 +-
drivers/net/wireless/mwifiex/sta_ioctl.c | 1081 +++-------------
drivers/net/wireless/mwifiex/sta_tx.c | 8 +-
drivers/net/wireless/mwifiex/txrx.c | 4 +-
drivers/net/wireless/mwifiex/util.c | 55 +-
drivers/net/wireless/mwifiex/wmm.c | 24 +-
drivers/net/wireless/mwifiex/wmm.h | 8 +-
drivers/net/wireless/mwl8k.c | 77 +-
drivers/net/wireless/rt2x00/Kconfig | 26 +-
drivers/net/wireless/rt2x00/Makefile | 1 -
drivers/net/wireless/rt2x00/rt2400pci.c | 29 +-
drivers/net/wireless/rt2x00/rt2500pci.c | 28 +-
drivers/net/wireless/rt2x00/rt2500usb.c | 85 +-
drivers/net/wireless/rt2x00/rt2800lib.c | 135 ++-
drivers/net/wireless/rt2x00/rt2800pci.c | 244 ++--
drivers/net/wireless/rt2x00/rt2800usb.c | 621 ++++++----
drivers/net/wireless/rt2x00/rt2x00.h | 97 +-
drivers/net/wireless/rt2x00/rt2x00config.c | 77 +-
drivers/net/wireless/rt2x00/rt2x00crypto.c | 4 +-
drivers/net/wireless/rt2x00/rt2x00debug.c | 42 +-
drivers/net/wireless/rt2x00/rt2x00dev.c | 23 +-
drivers/net/wireless/rt2x00/rt2x00firmware.c | 2 +-
drivers/net/wireless/rt2x00/rt2x00ht.c | 136 --
drivers/net/wireless/rt2x00/rt2x00lib.h | 34 +-
drivers/net/wireless/rt2x00/rt2x00link.c | 12 +-
drivers/net/wireless/rt2x00/rt2x00mac.c | 95 ++-
drivers/net/wireless/rt2x00/rt2x00pci.c | 12 +-
drivers/net/wireless/rt2x00/rt2x00pci.h | 12 +-
drivers/net/wireless/rt2x00/rt2x00queue.c | 159 ++-
drivers/net/wireless/rt2x00/rt2x00queue.h | 33 +-
drivers/net/wireless/rt2x00/rt2x00usb.c | 126 ++-
drivers/net/wireless/rt2x00/rt2x00usb.h | 31 +-
drivers/net/wireless/rt2x00/rt61pci.c | 64 +-
drivers/net/wireless/rt2x00/rt73usb.c | 189 ++--
drivers/net/wireless/rtlwifi/base.c | 12 +-
drivers/net/wireless/rtlwifi/pci.c | 3 +-
drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c | 2 +-
drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c | 2 +-
drivers/net/wireless/rtlwifi/rtl8192ce/led.c | 14 +-
drivers/net/wireless/rtlwifi/rtl8192ce/led.h | 1 -
drivers/net/wireless/rtlwifi/rtl8192ce/rf.c | 4 +-
drivers/net/wireless/rtlwifi/rtl8192ce/sw.c | 1 -
drivers/net/wireless/rtlwifi/rtl8192cu/hw.c | 2 +-
include/linux/nl80211.h | 34 +-
include/linux/rfkill-regulator.h | 48 +
include/net/bluetooth/l2cap.h | 130 +-
include/net/cfg80211.h | 33 +-
include/net/mac80211.h | 16 +
net/bluetooth/hci_event.c | 4 +
net/bluetooth/l2cap_core.c | 1344 +++++++++++---------
net/bluetooth/l2cap_sock.c | 72 +-
net/mac80211/cfg.c | 29 +-
net/mac80211/debugfs_sta.c | 26 +
net/mac80211/driver-ops.h | 13 +
net/mac80211/driver-trace.h | 20 +
net/mac80211/ieee80211_i.h | 5 +-
net/mac80211/main.c | 9 +-
net/mac80211/mesh.c | 14 +-
net/mac80211/mesh.h | 3 +-
net/mac80211/mesh_pathtbl.c | 49 +-
net/mac80211/mesh_plink.c | 35 +-
net/mac80211/mlme.c | 17 +-
net/mac80211/rx.c | 26 +-
net/mac80211/sta_info.c | 16 +-
net/mac80211/sta_info.h | 5 +
net/mac80211/tx.c | 2 +-
net/rfkill/Kconfig | 11 +
net/rfkill/Makefile | 1 +
net/rfkill/rfkill-regulator.c | 164 +++
net/wireless/mesh.c | 23 +-
net/wireless/nl80211.c | 67 +-
net/wireless/nl80211.h | 4 +
192 files changed, 7204 insertions(+), 5938 deletions(-)
create mode 100644 drivers/net/wireless/ath/ath9k/htc_drv_debug.c
delete mode 100644 drivers/net/wireless/iwlwifi/iwl-agn-led.c
delete mode 100644 drivers/net/wireless/iwlwifi/iwl-agn-led.h
delete mode 100644 drivers/net/wireless/rt2x00/rt2x00ht.c
create mode 100644 include/linux/rfkill-regulator.h
create mode 100644 net/rfkill/rfkill-regulator.c
Omnibus patch available here:
http://www.kernel.org/pub/linux/kernel/people/linville/wireless-next-2.6-2011-04-25.patch.bz2
--
John W. Linville Someday the world will need a hero, and you
linville@tuxdriver.com might be all we have. Be ready.
^ permalink raw reply
* Re: pull request: wireless-next-2.6 2011-04-25
From: David Miller @ 2011-04-25 19:58 UTC (permalink / raw)
To: linville-2XuSBdqkA4R54TAoqtyWWQ
Cc: linux-wireless-u79uwXL29TY76Z2rM5mHXA,
netdev-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <20110425193017.GC28814-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
From: "John W. Linville" <linville-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
Date: Mon, 25 Apr 2011 15:30:17 -0400
> Here is another big batch of updates intended for 2.6.40...
>
> There is the usual huge batch of changes for ath9k, and iwlagn, a bunch
> for ath9k_htc, rt2x00, and ath5k, a few more for mwifiex, and a handful
> of others. Also included is a big batch of Bluetooth updates as well.
>
> Please let me know if there are problems!
Pulled, thanks a lot John.
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: pull request: wireless-next-2.6 2011-04-25
From: David Miller @ 2011-04-25 20:04 UTC (permalink / raw)
To: linville-2XuSBdqkA4R54TAoqtyWWQ
Cc: linux-wireless-u79uwXL29TY76Z2rM5mHXA,
netdev-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <20110425.125835.189703400.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
From: David Miller <davem@davemloft.net>
Date: Mon, 25 Apr 2011 12:58:35 -0700 (PDT)
> From: "John W. Linville" <linville@tuxdriver.com>
> Date: Mon, 25 Apr 2011 15:30:17 -0400
>
>> Here is another big batch of updates intended for 2.6.40...
>>
>> There is the usual huge batch of changes for ath9k, and iwlagn, a bunch
>> for ath9k_htc, rt2x00, and ath5k, a few more for mwifiex, and a handful
>> of others. Also included is a big batch of Bluetooth updates as well.
>>
>> Please let me know if there are problems!
>
> Pulled, thanks a lot John.
I guess watching the build logs for new warnings is too old fashioned
for people, and besides Dave will do it for everyone anyways right?
And this one is a real bug too. :-/
I'll push this out to net-next-2.6 on top of the wireless-next pull,
but please be more mindful in the future.
--------------------
From bf734843120b905bacc3d24c88d7455ae70bf6e1 Mon Sep 17 00:00:00 2001
From: David S. Miller <davem@davemloft.net>
Date: Mon, 25 Apr 2011 13:03:02 -0700
Subject: [PATCH] bluetooth: Fix use-before-initiailized var.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
net/bluetooth/l2cap_core.c: In function ‘l2cap_recv_frame’:
net/bluetooth/l2cap_core.c:3612:15: warning: ‘sk’ may be used uninitialized in this function
net/bluetooth/l2cap_core.c:3612:15: note: ‘sk’ was declared here
Actually the problem is in the inline function l2cap_data_channel(), we
branch to the label 'done' which tests 'sk' before we set it to anything.
Initialize it to NULL to fix this.
Signed-off-by: David S. Miller <davem@davemloft.net>
---
net/bluetooth/l2cap_core.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index d47de2b..8cfa2a6 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -3609,7 +3609,7 @@ drop:
static inline int l2cap_data_channel(struct l2cap_conn *conn, u16 cid, struct sk_buff *skb)
{
struct l2cap_chan *chan;
- struct sock *sk;
+ struct sock *sk = NULL;
struct l2cap_pinfo *pi;
u16 control;
u8 tx_seq;
--
1.7.4.5
^ permalink raw reply related
* Re: [PATCH v4 1/1] can: add pruss CAN driver.
From: Wolfgang Grandegger @ 2011-04-25 20:06 UTC (permalink / raw)
To: Marc Kleine-Budde
Cc: sachi-EvXpCiN+lbve9wHmmfpqLFaTQe2KTcn/,
davinci-linux-open-source-VycZQUHpC/PFrsHnngEfi1aTQe2KTcn/,
Subhasish Ghosh, nsekhar-l0cyMroinI0, open list,
CAN NETWORK DRIVERS, Netdev-u79uwXL29TY76Z2rM5mHXA,
m-watkins-l0cyMroinI0,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
In-Reply-To: <4DB1A3B7.7060300-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
Hi,
On 04/22/2011 05:50 PM, Marc Kleine-Budde wrote:
> On 04/22/2011 02:11 PM, Subhasish Ghosh wrote:
>> This patch adds support for the CAN device emulated on PRUSS.
>
> After commenting the code inline, some remarks:
> - Your tx path looks broken, see commits inline
> - Please setup a proper struct to describe your register layout, make
> use of arrays for rx and tx
> - don't use u32, s32 for not hardware related variables like return
> codes and loop counter.
> - the routines that load and save the can data bytes from/into your
> mailbox look way to complicated. Please write down the layout so that
> we can think of a elegant way to do it
> - a lot of functions unconditionally return 0, make them void if no
> error can happen
> - think about using managed devices, that would simplify the probe and
> release function
I agree with Marc's comments and would like to add:
- Use just *one* value per sysfs file
A few more comments inline...
>> Signed-off-by: Subhasish Ghosh <subhasish-EvXpCiN+lbve9wHmmfpqLFaTQe2KTcn/@public.gmane.org>
>> ---
>> drivers/net/can/Kconfig | 7 +
>> drivers/net/can/Makefile | 1 +
>> drivers/net/can/pruss_can.c | 1074 +++++++++++++++++++++++++++++++++++++++++++
>> 3 files changed, 1082 insertions(+), 0 deletions(-)
>> create mode 100644 drivers/net/can/pruss_can.c
>>
>> diff --git a/drivers/net/can/Kconfig b/drivers/net/can/Kconfig
>> index 5dec456..4682a4f 100644
>> --- a/drivers/net/can/Kconfig
>> +++ b/drivers/net/can/Kconfig
>> @@ -111,6 +111,13 @@ config PCH_CAN
>> embedded processor.
>> This driver can access CAN bus.
>>
>> +config CAN_TI_DA8XX_PRU
>> + depends on CAN_DEV && ARCH_DAVINCI && ARCH_DAVINCI_DA850
>> + tristate "PRU based CAN emulation for DA8XX"
>> + ---help---
>> + Enable this to emulate a CAN controller on the PRU of DA8XX.
>> + If not sure, mark N
>
> Please indent the help text with 1 tab and 2 spaces
>
>> +
>> source "drivers/net/can/mscan/Kconfig"
>>
>> source "drivers/net/can/sja1000/Kconfig"
>> diff --git a/drivers/net/can/Makefile b/drivers/net/can/Makefile
>> index 53c82a7..d0b7cbd 100644
>> --- a/drivers/net/can/Makefile
>> +++ b/drivers/net/can/Makefile
>> @@ -15,6 +15,7 @@ obj-$(CONFIG_CAN_SJA1000) += sja1000/
>> obj-$(CONFIG_CAN_MSCAN) += mscan/
>> obj-$(CONFIG_CAN_AT91) += at91_can.o
>> obj-$(CONFIG_CAN_TI_HECC) += ti_hecc.o
>> +obj-$(CONFIG_CAN_TI_DA8XX_PRU) += pruss_can.o
>> obj-$(CONFIG_CAN_MCP251X) += mcp251x.o
>> obj-$(CONFIG_CAN_BFIN) += bfin_can.o
>> obj-$(CONFIG_CAN_JANZ_ICAN3) += janz-ican3.o
>> diff --git a/drivers/net/can/pruss_can.c b/drivers/net/can/pruss_can.c
>> new file mode 100644
>> index 0000000..7702509
>> --- /dev/null
>> +++ b/drivers/net/can/pruss_can.c
...
> is this array const?
>> +static u32 pruss_intc_init[19][3] = {
>> + {PRUSS_INTC_POLARITY0, PRU_INTC_REGMAP_MASK, 0xFFFFFFFF},
>> + {PRUSS_INTC_POLARITY1, PRU_INTC_REGMAP_MASK, 0xFFFFFFFF},
>> + {PRUSS_INTC_TYPE0, PRU_INTC_REGMAP_MASK, 0x1C000000},
>> + {PRUSS_INTC_TYPE1, PRU_INTC_REGMAP_MASK, 0},
>> + {PRUSS_INTC_GLBLEN, 0, 1},
>> + {PRUSS_INTC_HOSTMAP0, PRU_INTC_REGMAP_MASK, 0x03020100},
>> + {PRUSS_INTC_HOSTMAP1, PRU_INTC_REGMAP_MASK, 0x07060504},
>> + {PRUSS_INTC_HOSTMAP2, PRU_INTC_REGMAP_MASK, 0x0000908},
>> + {PRUSS_INTC_CHANMAP0, PRU_INTC_REGMAP_MASK, 0},
>> + {PRUSS_INTC_CHANMAP8, PRU_INTC_REGMAP_MASK, 0x00020200},
>> + {PRUSS_INTC_STATIDXCLR, 0, 32},
>> + {PRUSS_INTC_STATIDXCLR, 0, 19},
>> + {PRUSS_INTC_ENIDXSET, 0, 19},
>> + {PRUSS_INTC_STATIDXCLR, 0, 18},
>> + {PRUSS_INTC_ENIDXSET, 0, 18},
>> + {PRUSS_INTC_STATIDXCLR, 0, 34},
>> + {PRUSS_INTC_ENIDXSET, 0, 34},
>> + {PRUSS_INTC_ENIDXSET, 0, 32},
>> + {PRUSS_INTC_HOSTINTEN, 0, 5}
>
> please add ","
Also a struct to describe each entry would improve readability.
Then you could also use ARRAY_SIZE.
>> +};
...
>> +static int pru_can_set_bittiming(struct net_device *ndev)
>> +{
>> + struct can_emu_priv *priv = netdev_priv(ndev);
>> + struct can_bittiming *bt = &priv->can.bittiming;
>> + u32 value;
>> +
>> + value = priv->can.clock.freq / bt->bitrate;
>> + pruss_writel(priv->dev, PRUSS_CAN_TIMING_VAL_TX, value);
>> + pruss_writel(priv->dev, PRUSS_CAN_BIT_TIMING_VAL_RX, value);
>> +
>> + value = (bt->phase_seg2 + bt->phase_seg1 +
>> + bt->prop_seg + 1) * bt->brp;
>> + value = (value >> 1) - PRUSS_CAN_TIMER_SETUP_DELAY;
>> + value = (value << 16) | value;
>> + pruss_writel(priv->dev, PRUSS_CAN_TIMING_VAL_RX, value);
>> +
>> + value = (PRUSS_CAN_GPIO_SETUP_DELAY *
>> + (priv->clk_freq_pru / 1000000) / 1000) /
>> + PRUSS_CAN_DELAY_LOOP_LENGTH;
This calculation looks delicate. 64-bit math would be safer.
>> +
>> + pruss_writel(priv->dev, PRUSS_CAN_TIMING_SETUP, value);
>> + return 0;
>> +}
...
>> +static int pru_can_err(struct net_device *ndev, int int_status,
>> + int err_status)
>> +{
>> + struct can_emu_priv *priv = netdev_priv(ndev);
>> + struct net_device_stats *stats = &ndev->stats;
>> + struct can_frame *cf;
>> + struct sk_buff *skb;
>> + u32 tx_err_cnt, rx_err_cnt;
>> +
>> + skb = alloc_can_err_skb(ndev, &cf);
>> + if (!skb) {
>> + if (printk_ratelimit())
>> + dev_err(priv->dev,
>> + "alloc_can_err_skb() failed\n");
>> + return -ENOMEM;
>> + }
>> +
>> + if (err_status & PRUSS_CAN_GSR_BIT_EPM) { /* error passive int */
>> + priv->can.state = CAN_STATE_ERROR_PASSIVE;
>> + ++priv->can.can_stats.error_passive;
>> + cf->can_id |= CAN_ERR_CRTL;
>> + tx_err_cnt = pru_can_get_error_cnt(priv->dev,
>> + PRUSS_CAN_TX_PRU_1);
>> + rx_err_cnt = pru_can_get_error_cnt(priv->dev,
>> + PRUSS_CAN_RX_PRU_0);
>> + if (tx_err_cnt > PRUSS_CAN_ERROR_ACTIVE - 1)
>> + cf->data[1] |= CAN_ERR_CRTL_TX_PASSIVE;
>> + if (rx_err_cnt > PRUSS_CAN_ERROR_ACTIVE - 1)
>> + cf->data[1] |= CAN_ERR_CRTL_RX_PASSIVE;
>> +
>> + dev_dbg(priv->ndev->dev.parent, "Error passive interrupt\n");
>> + }
>> +
>> + if (err_status & PRUSS_CAN_GSR_BIT_BFM) {
>> + priv->can.state = CAN_STATE_BUS_OFF;
>> + cf->can_id |= CAN_ERR_BUSOFF;
>> + /*
>> + * Disable all interrupts in bus-off to avoid int hog
>> + * this should be handled by the pru
>> + */
>> + pru_can_mask_ints(priv->dev, PRUSS_CAN_TX_PRU_1, false);
>> + pru_can_mask_ints(priv->dev, PRUSS_CAN_RX_PRU_0, false);
>> + can_bus_off(ndev);
>> + dev_dbg(priv->ndev->dev.parent, "Bus off mode\n");
>> + }
>> +
>> + netif_rx(skb);
You should use netif_receive_skb(skb) here as well.
>> + stats->rx_packets++;
>> + stats->rx_bytes += cf->can_dlc;
>> + return 0;
>> +}
>> +
>> +static int pru_can_rx_poll(struct napi_struct *napi, int quota)
>> +{
>> + struct net_device *ndev = napi->dev;
>> + struct can_emu_priv *priv = netdev_priv(ndev);
>> + u32 bit_set, mbxno = 0;
>> + u32 num_pkts = 0;
>> +
>> + if (!netif_running(ndev))
>> + return 0;
>> +
>> + do {
>> + /* rx int sys_evt -> 33 */
>> + pru_can_clr_intc_status(priv->dev, PRUSS_CAN_RX_PRU_0);
>> + if (pru_can_intr_stat_get(priv->dev, &priv->can_rx_cntx))
>> + return num_pkts;
>> +
>> + if (PRUSS_CAN_ISR_BIT_RRI & priv->can_rx_cntx.intr_stat) {
>> + mbxno = PRUSS_CAN_RTR_BUFF_NUM;
>> + pru_can_rx(ndev, mbxno);
>> + num_pkts++;
>> + } else {
>> + /* Extract the mboxno from the status */
>> + bit_set = fls(priv->can_rx_cntx.intr_stat & 0xFF);
>> + if (bit_set) {
>> + num_pkts++;
>> + mbxno = bit_set - 1;
>> + if (PRUSS_CAN_ISR_BIT_ESI & priv->can_rx_cntx.
>> + intr_stat) {
if (PRUSS_CAN_ISR_BIT_ESI &
priv->can_rx_cntx.intr_stat) {
Is more readable.
>> + pru_can_gbl_stat_get(priv->dev,
>> + &priv->can_rx_cntx);
>> + pru_can_err(ndev,
>> + priv->can_rx_cntx.intr_stat,
>> + priv->can_rx_cntx.gbl_stat);
Please fix bogous indention.
>> + } else
>> + pru_can_rx(ndev, mbxno);
>> + } else
>> + break;
>> + }
>> + } while (((PRUSS_CAN_TX_INT_STAT & pru_can_get_intc_status(priv->dev))
>> + && (num_pkts < quota)));
>> +
>> + /* Enable packet interrupt if all pkts are handled */
>> + if (!(PRUSS_CAN_TX_INT_STAT & pru_can_get_intc_status(priv->dev))) {
>> + napi_complete(napi);
>> + /* Re-enable RX mailbox interrupts */
>> + pru_can_mask_ints(priv->dev, PRUSS_CAN_RX_PRU_0, true);
>> + }
>> + return num_pkts;
>> +}
...
>> +/* Shows all the mailbox IDs */
>> +static ssize_t pru_sysfs_mbx_id_show(struct device *dev,
>> + struct device_attribute *attr, char *buf)
>> +{
>> + struct can_emu_priv *priv = netdev_priv(to_net_dev(dev));
>> +
>> + return snprintf(buf, PAGE_SIZE, "<mbx_no:mbx_id>\n"
>> + "0:0x%X 1:0x%X 2:0x%X 3:0x%X "
>> + "4:0x%X 5:0x%X 6:0x%X 7:0x%X\n",
>> + priv->mbx_id[0], priv->mbx_id[1],
>> + priv->mbx_id[2], priv->mbx_id[3],
>> + priv->mbx_id[4], priv->mbx_id[5],
>> + priv->mbx_id[6], priv->mbx_id[7]);
>> +}
As mentioned above, just one value per sysfs file, please...
>> +/*
>> + * Sets Mailbox IDs
>> + * This should be programmed as mbx_num:mbx_id (in hex)
>> + * eg: $ echo 0:0x123 > /sys/class/net/can0/mbx_id
>> + */
... which would also avoid string parsing.
>> +static int __devinit pru_can_probe(struct platform_device *pdev)
>> +{
>> + struct net_device *ndev = NULL;
>> + const struct da850_evm_pruss_can_data *pdata;
>> + struct can_emu_priv *priv = NULL;
>> + struct device *dev = &pdev->dev;
>> + struct clk *clk_pruss;
>> + const struct firmware *fw_rx;
>> + const struct firmware *fw_tx;
>> + u32 err;
> use int
>> +
>> + pdata = dev->platform_data;
>> + if (!pdata) {
>> + dev_err(&pdev->dev, "platform data not found\n");
>> + return -EINVAL;
>> + }
>> + (pdata->setup)();
>
> no need fot the ( )
>
>> +
>> + ndev = alloc_candev(sizeof(struct can_emu_priv), PRUSS_CAN_MB_MAX + 1);
>> + if (!ndev) {
>> + dev_err(&pdev->dev, "alloc_candev failed\n");
>> + err = -ENOMEM;
>> + goto probe_exit;
>> + }
>> +
>> + ndev->sysfs_groups[0] = &pru_sysfs_attr_group;
>> +
>> + priv = netdev_priv(ndev);
>> +
>> + priv->trx_irq = platform_get_irq(to_platform_device(dev->parent), 0);
>> + if (!priv->trx_irq) {
>> + dev_err(&pdev->dev, "unable to get pru "
>> + "interrupt resources!\n");
>> + err = -ENODEV;
>> + goto probe_exit;
>> + }
>> +
>> + priv->ndev = ndev;
>> + priv->dev = dev;
>> +
>> + priv->can.bittiming_const = &pru_can_bittiming_const;
>> + priv->can.do_set_bittiming = pru_can_set_bittiming;
>> + priv->can.do_set_mode = pru_can_set_mode;
>> + priv->can.do_get_state = pru_can_get_state;
Please remove that callback. It's not needed as state changes are
handled properly.
>> + priv->can_tx_cntx.pruno = PRUSS_CAN_TX_PRU_1;
>> + priv->can_rx_cntx.pruno = PRUSS_CAN_RX_PRU_0;
>> +
>> + /* we support local echo, no arp */
>> + ndev->flags |= (IFF_ECHO | IFF_NOARP);
>
> no need to se NOARP
>
>> +
>> + /* pdev->dev->device_private->driver_data = ndev */
>> + platform_set_drvdata(pdev, ndev);
>> + SET_NETDEV_DEV(ndev, &pdev->dev);
>> + ndev->netdev_ops = &pru_can_netdev_ops;
>> +
>> + priv->clk_timer = clk_get(&pdev->dev, "pll1_sysclk2");
>> + if (IS_ERR(priv->clk_timer)) {
>> + dev_err(&pdev->dev, "no timer clock available\n");
>> + err = PTR_ERR(priv->clk_timer);
>> + priv->clk_timer = NULL;
>> + goto probe_exit_candev;
>> + }
>> +
>> + priv->can.clock.freq = clk_get_rate(priv->clk_timer);
>> +
>> + clk_pruss = clk_get(NULL, "pruss");
>> + if (IS_ERR(clk_pruss)) {
>> + dev_err(&pdev->dev, "no clock available: pruss\n");
>> + err = -ENODEV;
>> + goto probe_exit_clk;
>> + }
>> + priv->clk_freq_pru = clk_get_rate(clk_pruss);
>> + clk_put(clk_pruss);
>
> why do you put the clock here?
>> +
>> + err = register_candev(ndev);
>> + if (err) {
>> + dev_err(&pdev->dev, "register_candev() failed\n");
>> + err = -ENODEV;
>> + goto probe_exit_clk;
>> + }
>> +
>> + err = request_firmware(&fw_tx, "PRU_CAN_Emulation_Tx.bin",
>> + &pdev->dev);
>> + if (err) {
>> + dev_err(&pdev->dev, "can't load firmware\n");
>> + err = -ENODEV;
>> + goto probe_exit_clk;
>> + }
>> +
>> + dev_info(&pdev->dev, "fw_tx size %d. downloading...\n", fw_tx->size);
>> +
>> + err = request_firmware(&fw_rx, "PRU_CAN_Emulation_Rx.bin",
>> + &pdev->dev);
>> + if (err) {
>> + dev_err(&pdev->dev, "can't load firmware\n");
>> + err = -ENODEV;
>> + goto probe_release_fw;
>> + }
>> + dev_info(&pdev->dev, "fw_rx size %d. downloading...\n", fw_rx->size);
>> +
>> + /* init the pru */
>> + pru_can_emu_init(priv->dev, priv->can.clock.freq);
>> + udelay(200);
>> +
>> + netif_napi_add(ndev, &priv->napi, pru_can_rx_poll,
>> + PRUSS_DEF_NAPI_WEIGHT);
>
> personally I'd wait to add the interface to napi until the firmware is
> loaded.
>
>> +
>> + pruss_enable(priv->dev, PRUSS_CAN_RX_PRU_0);
>> + pruss_enable(priv->dev, PRUSS_CAN_TX_PRU_1);
>> +
>> + /* download firmware into pru */
>> + err = pruss_load(priv->dev, PRUSS_CAN_RX_PRU_0,
>> + (u32 *)fw_rx->data, (fw_rx->size / 4));
>> + if (err) {
>> + dev_err(&pdev->dev, "firmware download error\n");
>> + err = -ENODEV;
>> + goto probe_release_fw_1;
>> + }
>> + release_firmware(fw_rx);
>> + err = pruss_load(priv->dev, PRUSS_CAN_TX_PRU_1,
>> + (u32 *)fw_tx->data, (fw_tx->size / 4));
>> + if (err) {
>> + dev_err(&pdev->dev, "firmware download error\n");
>> + err = -ENODEV;
>> + goto probe_release_fw_1;
>> + }
>> + release_firmware(fw_tx);
>> +
>> + pruss_run(priv->dev, PRUSS_CAN_RX_PRU_0);
>> + pruss_run(priv->dev, PRUSS_CAN_TX_PRU_1);
>> +
>> + dev_info(&pdev->dev,
>> + "%s device registered (trx_irq = %d, clk = %d)\n",
>> + PRUSS_CAN_DRV_NAME, priv->trx_irq, priv->can.clock.freq);
>> +
>> + return 0;
>> +
>> +probe_release_fw_1:
>> + release_firmware(fw_rx);
>> +probe_release_fw:
>> + release_firmware(fw_tx);
>> +probe_exit_clk:
>> + clk_put(priv->clk_timer);
>> +probe_exit_candev:
>> + if (NULL != ndev)
>> + free_candev(ndev);
>> +probe_exit:
>> + return err;
>> +}
Thanks,
Wolfgang.
^ permalink raw reply
* Re: pull request: wireless-next-2.6 2011-04-25
From: Larry Finger @ 2011-04-25 20:55 UTC (permalink / raw)
To: David Miller; +Cc: linville, linux-wireless, netdev
In-Reply-To: <20110425.130435.112597353.davem@davemloft.net>
On 04/25/2011 03:04 PM, David Miller wrote:
> From: David Miller<davem@davemloft.net>
> Date: Mon, 25 Apr 2011 12:58:35 -0700 (PDT)
>
>> From: "John W. Linville"<linville@tuxdriver.com>
>> Date: Mon, 25 Apr 2011 15:30:17 -0400
>>
>>> Here is another big batch of updates intended for 2.6.40...
>>>
>>> There is the usual huge batch of changes for ath9k, and iwlagn, a bunch
>>> for ath9k_htc, rt2x00, and ath5k, a few more for mwifiex, and a handful
>>> of others. Also included is a big batch of Bluetooth updates as well.
>>>
>>> Please let me know if there are problems!
>>
>> Pulled, thanks a lot John.
>
> I guess watching the build logs for new warnings is too old fashioned
> for people, and besides Dave will do it for everyone anyways right?
>
> And this one is a real bug too. :-/
>
> I'll push this out to net-next-2.6 on top of the wireless-next pull,
> but please be more mindful in the future.
Unfortunately, the 64-bit variant of gcc v4.5.1 will miss some of these. I find
I need to compile code on a 32-bit system and using an older compiler to catch
all. Perhaps that explains the error that crept through here.
Larry
^ permalink raw reply
* [PATCH v4 00/27] HFI: minimal device driver/ip driver
From: dykmanj @ 2011-04-25 21:23 UTC (permalink / raw)
To: netdev; +Cc: Jim Dykman
From: Jim Dykman <dykmanj@linux.vnet.ibm.com>
The HFI ("Host Fabric Interface") network interface is the internal cluster
fabric of IBM's PERCS supercomputer. The hardware design is under US export
control, so we cannot release hardware specs. There is a writeup of
publically available information about the system available here:
http://sourceforge.net/projects/hfidevicedriver/files/docs/hfi_general_desc_v2.1.txt
hfi_core contains the resource management to set up communications paths for
network traffic. Calls are provided for kernel drivers, and also for setting
up direct user-space access to HFI windows.
hfi_ip contains the kernel network driver.
The driver has been running in the lab for several months. The full patch is
around 22000 lines, so we've split out a minimal device/network driver that
can send and receive through the simplest path. Once that much gets accepted
we'll start adding on to it.
Patches are against net-next-2.6.
Jim Dykman
Changelog:
----------
v4: Don't include <linux/vermagic.h>
v3: Don't include <linux/version.h>
hfidd_mod_init: return -1; --> return rc;
hfidd_alloc_adapter: pass snprintf xiHFI_DEVICE_NAME_MAX,
not HFI_DEVICE_NAME_MAX -1
change HFI_DEVICE_NAME_MAX from 64 to 8
v2:
Remove return; at the end of void funcs
hfidd_free_adapter: p_acs = NULL unneccesssary, remove
remove net_stats, and use netdev->stats, remove hf_get_stats
rename network driver to hfi_ip
hf_inet_event: NETDEV_UP needs to check event is for us, check
netdev->netdev_ops == ours
change printk()s to netdev_err() and friends
hf_net_close: remove redundant CLOSE check
hf_change_mtu: minimum mtu should be 68
remove NETIF_F_SG flag
hf_init_netdev: Use ERR_PTR
hf_init_module: %ld / formatting
pass up return code from failed call
use unsigned int instead of u32 for bit fields <32 bits
use struct ethhdr instead of hf_hwhdr
hf_get_sset_count: default return -EINVAL not -EOPNOTSUPP
Remove "hfidd_callback_event: enter" message that printed on every
recv interrupt
hfidd_destroy_devices: hfidd_rmdev() after hfidd_free_adapter() so
dev_printk doesn't oops on rmmod
^ permalink raw reply
* [PATCH v4 01/27] HFI: skeleton driver
From: dykmanj @ 2011-04-25 21:23 UTC (permalink / raw)
To: netdev
Cc: Jim Dykman, Piyush Chaudhary, Fu-Chung Chang, William S. Cadden,
Wen C. Chen, Scot Sakolish, Jian Xiao, Carol L. Soto,
Sarah J. Sheppard
In-Reply-To: <1303766647-30156-1-git-send-email-dykmanj@linux.vnet.ibm.com>
From: Jim Dykman <dykmanj@linux.vnet.ibm.com>
Device driver Makefile & Kconfig plumbing plus simple mod_init and mod_exit
Signed-off-by: Piyush Chaudhary <piyushc@linux.vnet.ibm.com>
Signed-off-by: Jim Dykman <dykmanj@linux.vnet.ibm.com>
Signed-off-by: Fu-Chung Chang <fcchang@linux.vnet.ibm.com>
Signed-off-by: William S. Cadden <wscadden@linux.vnet.ibm.com>
Signed-off-by: Wen C. Chen <winstonc@linux.vnet.ibm.com>
Signed-off-by: Scot Sakolish <sakolish@linux.vnet.ibm.com>
Signed-off-by: Jian Xiao <jian@linux.vnet.ibm.com>
Signed-off-by: Carol L. Soto <clsoto@linux.vnet.ibm.com>
Signed-off-by: Sarah J. Sheppard <sjsheppa@linux.vnet.ibm.com>
---
drivers/net/Kconfig | 2 +
drivers/net/Makefile | 2 +
drivers/net/hfi/Makefile | 1 +
drivers/net/hfi/core/Kconfig | 8 ++
drivers/net/hfi/core/Makefile | 5 ++
drivers/net/hfi/core/hfidd_init.c | 141 ++++++++++++++++++++++++++++++++++++
include/linux/Kbuild | 1 +
include/linux/hfi/Kbuild | 1 +
include/linux/hfi/hfidd_client.h | 40 ++++++++++
include/linux/hfi/hfidd_internal.h | 53 ++++++++++++++
10 files changed, 254 insertions(+), 0 deletions(-)
create mode 100644 drivers/net/hfi/Makefile
create mode 100644 drivers/net/hfi/core/Kconfig
create mode 100644 drivers/net/hfi/core/Makefile
create mode 100644 drivers/net/hfi/core/hfidd_init.c
create mode 100644 include/linux/hfi/Kbuild
create mode 100644 include/linux/hfi/hfidd_client.h
create mode 100644 include/linux/hfi/hfidd_internal.h
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index dc280bc..1abbfd9 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -3436,4 +3436,6 @@ config VMXNET3
To compile this driver as a module, choose M here: the
module will be called vmxnet3.
+source "drivers/net/hfi/core/Kconfig"
+
endif # NETDEVICES
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 01b604a..e9ea418 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -304,3 +304,5 @@ obj-$(CONFIG_CAIF) += caif/
obj-$(CONFIG_OCTEON_MGMT_ETHERNET) += octeon/
obj-$(CONFIG_PCH_GBE) += pch_gbe/
obj-$(CONFIG_TILE_NET) += tile/
+
+obj-$(CONFIG_HFI) += hfi/
diff --git a/drivers/net/hfi/Makefile b/drivers/net/hfi/Makefile
new file mode 100644
index 0000000..0440cbe
--- /dev/null
+++ b/drivers/net/hfi/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_HFI) += core/
diff --git a/drivers/net/hfi/core/Kconfig b/drivers/net/hfi/core/Kconfig
new file mode 100644
index 0000000..3cd637c
--- /dev/null
+++ b/drivers/net/hfi/core/Kconfig
@@ -0,0 +1,8 @@
+config HFI
+ tristate "HFI driver support"
+ depends on IBMEBUS
+ ---help---
+ This driver supports the IBM System p HFI adapter.
+
+ To compile the driver as a module, choose M here. The module
+ will be called hfi_core.
diff --git a/drivers/net/hfi/core/Makefile b/drivers/net/hfi/core/Makefile
new file mode 100644
index 0000000..80790c6
--- /dev/null
+++ b/drivers/net/hfi/core/Makefile
@@ -0,0 +1,5 @@
+#
+# Makefile for the HFI device driver for IBM eServer System p
+#
+hfi_core-objs:= hfidd_init.o
+obj-$(CONFIG_HFI) += hfi_core.o
diff --git a/drivers/net/hfi/core/hfidd_init.c b/drivers/net/hfi/core/hfidd_init.c
new file mode 100644
index 0000000..9498faf
--- /dev/null
+++ b/drivers/net/hfi/core/hfidd_init.c
@@ -0,0 +1,141 @@
+/*
+ * hfidd_init.c
+ *
+ * HFI device driver for IBM System p
+ *
+ * Authors:
+ * Fu-Chung Chang <fcchang@linux.vnet.ibm.com>
+ * William S. Cadden <wscadden@linux.vnet.ibm.com>
+ * Wen C. Chen <winstonc@linux.vnet.ibm.com>
+ * Scot Sakolish <sakolish@linux.vnet.ibm.com>
+ * Jian Xiao <jian@linux.vnet.ibm.com>
+ * Carol L. Soto <clsoto@linux.vnet.ibm.com>
+ * Sarah J. Sheppard <sjsheppa@linux.vnet.ibm.com>
+ *
+ * (C) Copyright IBM Corp. 2010
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/device.h>
+
+#include <linux/hfi/hfidd_internal.h>
+
+MODULE_VERSION("1.0");
+MODULE_DESCRIPTION("Device Driver for IBM eServer HFI for IBM System p");
+MODULE_AUTHOR("James Dykman <dykmanj@linux.vnet.ibm.com> and "
+ "Piyush Chaudhary <piyushc@linux.vnet.ibm.com>");
+MODULE_LICENSE("GPL v2");
+
+struct hfidd_global hfidd_global;
+EXPORT_SYMBOL_GPL(hfidd_global);
+
+static dev_t hfidd_dev;
+
+#define MAX_HFI_DEVS (MAX_HFIS + 1)
+
+/* Function to get our internal traces */
+static ssize_t hfidd_read(struct file *filep, char *buf, size_t count,
+ loff_t *pos)
+{
+ return 0;
+}
+
+/* Entry point for user space to do driver requests. */
+static ssize_t hfidd_cmd_write(struct file *filep, const char __user *buf,
+ size_t count, loff_t *pos)
+{
+ return 0;
+}
+
+static const struct file_operations hfidd_fops = {
+ .owner = THIS_MODULE,
+ .read = hfidd_read,
+ .write = hfidd_cmd_write,
+};
+
+/* Destroy the HFI class */
+static inline void hfidd_destroy_class(void)
+{
+ class_destroy(hfidd_global.class);
+ cdev_del(&hfidd_global.cdev);
+ unregister_chrdev_region(hfidd_dev, MAX_HFI_DEVS);
+}
+
+/* Create the HFI class */
+static int hfidd_create_class(void)
+{
+ int rc;
+
+ rc = alloc_chrdev_region(&hfidd_dev, 0, MAX_HFI_DEVS, HFIDD_DEV_NAME);
+ if (rc) {
+ printk(KERN_ERR "%s: hfidd_create_class: alloc_chrdev_region"
+ " failed rc 0x%x\n", HFIDD_DEV_NAME, rc);
+ return rc;
+ }
+
+ cdev_init(&hfidd_global.cdev, &hfidd_fops);
+ hfidd_global.cdev.owner = THIS_MODULE;
+ kobject_set_name(&hfidd_global.cdev.kobj, HFIDD_DEV_NAME);
+ rc = cdev_add(&hfidd_global.cdev, hfidd_dev, MAX_HFI_DEVS);
+ if (rc) {
+ printk(KERN_ERR "%s: hfidd_create_class cdev_add fail"
+ " rc = %d\n", HFIDD_DEV_NAME, rc);
+ goto hfidd_create_class_error1;
+ }
+
+ hfidd_global.class = class_create(THIS_MODULE, HFIDD_CLASS_NAME);
+ if (IS_ERR(hfidd_global.class)) {
+ rc = PTR_ERR(hfidd_global.class);
+ printk(KERN_ERR "%s: hfidd_create_class class_create fail rc = %d\n",
+ HFIDD_DEV_NAME, rc);
+ goto hfidd_create_class_error2;
+ }
+
+ return rc;
+
+hfidd_create_class_error2:
+ cdev_del(&hfidd_global.cdev);
+hfidd_create_class_error1:
+ unregister_chrdev_region(hfidd_dev, MAX_HFI_DEVS);
+
+ return rc;
+}
+
+static int __init hfidd_mod_init(void)
+{
+ int rc = 0;
+
+ rc = hfidd_create_class();
+ if (rc < 0) {
+ printk(KERN_ERR "%s: hfidd_mod_init: hfidd_create_class failed"
+ " rc=%d\n", HFIDD_DEV_NAME, rc);
+ return rc;
+ }
+
+ printk(KERN_INFO "IBM hfi device driver loaded sucessfully\n");
+ return 0;
+}
+
+static void __exit hfidd_mod_exit(void)
+{
+ hfidd_destroy_class();
+}
+
+module_init(hfidd_mod_init);
+module_exit(hfidd_mod_exit);
diff --git a/include/linux/Kbuild b/include/linux/Kbuild
index 75cf611..df925b4 100644
--- a/include/linux/Kbuild
+++ b/include/linux/Kbuild
@@ -3,6 +3,7 @@ header-y += can/
header-y += caif/
header-y += dvb/
header-y += hdlc/
+header-y += hfi/
header-y += isdn/
header-y += nfsd/
header-y += raid/
diff --git a/include/linux/hfi/Kbuild b/include/linux/hfi/Kbuild
new file mode 100644
index 0000000..3a742ce
--- /dev/null
+++ b/include/linux/hfi/Kbuild
@@ -0,0 +1 @@
+header-y += hfidd_client.h
diff --git a/include/linux/hfi/hfidd_client.h b/include/linux/hfi/hfidd_client.h
new file mode 100644
index 0000000..b738f4b
--- /dev/null
+++ b/include/linux/hfi/hfidd_client.h
@@ -0,0 +1,40 @@
+/*
+ * hfidd_client.h
+ *
+ * HFI device driver for IBM System p
+ *
+ * Authors:
+ * Fu-Chung Chang <fcchang@linux.vnet.ibm.com>
+ * William S. Cadden <wscadden@linux.vnet.ibm.com>
+ * Wen C. Chen <winstonc@linux.vnet.ibm.com>
+ * Scot Sakolish <sakolish@linux.vnet.ibm.com>
+ * Jian Xiao <jian@linux.vnet.ibm.com>
+ * Carol L. Soto <clsoto@linux.vnet.ibm.com>
+ * Sarah J. Sheppard <sjsheppa@linux.vnet.ibm.com>
+ *
+ * (C) Copyright IBM Corp. 2010
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#ifndef _HFIDD_CLIENT_H_
+#define _HFIDD_CLIENT_H_
+
+#define MAX_TORRENTS 1
+#define MAX_HFI_PER_TORRENT 2
+#define MAX_HFIS (MAX_TORRENTS * MAX_HFI_PER_TORRENT)
+
+#endif /* _HFIDD_CLIENT_H_ */
diff --git a/include/linux/hfi/hfidd_internal.h b/include/linux/hfi/hfidd_internal.h
new file mode 100644
index 0000000..f5de1bb
--- /dev/null
+++ b/include/linux/hfi/hfidd_internal.h
@@ -0,0 +1,53 @@
+/*
+ * hfidd_internal.h
+ *
+ * HFI device driver for IBM System p
+ *
+ * Authors:
+ * Fu-Chung Chang <fcchang@linux.vnet.ibm.com>
+ * William S. Cadden <wscadden@linux.vnet.ibm.com>
+ * Wen C. Chen <winstonc@linux.vnet.ibm.com>
+ * Scot Sakolish <sakolish@linux.vnet.ibm.com>
+ * Jian Xiao <jian@linux.vnet.ibm.com>
+ * Carol L. Soto <clsoto@linux.vnet.ibm.com>
+ * Sarah J. Sheppard <sjsheppa@linux.vnet.ibm.com>
+ *
+ * (C) Copyright IBM Corp. 2010
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#ifndef _HFI_INTERNAL_H_
+#define _HFI_INTERNAL_H_
+
+#include <linux/fs.h>
+#include <linux/kobject.h>
+#include <linux/cdev.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+
+#include <linux/hfi/hfidd_client.h>
+
+#define HFIDD_DEV_NAME "hfi"
+#define HFIDD_CLASS_NAME "hfi"
+
+/* DD global */
+struct hfidd_global {
+ struct cdev cdev;
+ struct class *class;
+};
+
+#endif
--
1.7.3.5
^ permalink raw reply related
* [PATCH v4 03/27] HFI: Add device_create/device_destroy calls for HFI devices.
From: dykmanj @ 2011-04-25 21:23 UTC (permalink / raw)
To: netdev
Cc: Jim Dykman, Piyush Chaudhary, Fu-Chung Chang, William S. Cadden,
Wen C. Chen, Scot Sakolish, Jian Xiao, Carol L. Soto,
Sarah J. Sheppard
In-Reply-To: <1303766647-30156-1-git-send-email-dykmanj@linux.vnet.ibm.com>
From: Jim Dykman <dykmanj@linux.vnet.ibm.com>
Signed-off-by: Piyush Chaudhary <piyushc@linux.vnet.ibm.com>
Signed-off-by: Jim Dykman <dykmanj@linux.vnet.ibm.com>
Signed-off-by: Fu-Chung Chang <fcchang@linux.vnet.ibm.com>
Signed-off-by: William S. Cadden <wscadden@linux.vnet.ibm.com>
Signed-off-by: Wen C. Chen <winstonc@linux.vnet.ibm.com>
Signed-off-by: Scot Sakolish <sakolish@linux.vnet.ibm.com>
Signed-off-by: Jian Xiao <jian@linux.vnet.ibm.com>
Signed-off-by: Carol L. Soto <clsoto@linux.vnet.ibm.com>
Signed-off-by: Sarah J. Sheppard <sjsheppa@linux.vnet.ibm.com>
---
drivers/net/hfi/core/hfidd_init.c | 52 ++++++++++++++++++++++++++++++++++++
include/linux/hfi/hfidd_internal.h | 1 +
2 files changed, 53 insertions(+), 0 deletions(-)
diff --git a/drivers/net/hfi/core/hfidd_init.c b/drivers/net/hfi/core/hfidd_init.c
index 61ed559..40d5aaf 100644
--- a/drivers/net/hfi/core/hfidd_init.c
+++ b/drivers/net/hfi/core/hfidd_init.c
@@ -46,6 +46,7 @@ MODULE_LICENSE("GPL v2");
struct hfidd_global hfidd_global;
EXPORT_SYMBOL_GPL(hfidd_global);
+struct device *hfidd_class_dev[MAX_HFIS + 1];
static dev_t hfidd_dev;
#define MAX_HFI_DEVS (MAX_HFIS + 1)
@@ -70,6 +71,38 @@ static const struct file_operations hfidd_fops = {
.write = hfidd_cmd_write,
};
+/* Create the hfi device */
+static int hfidd_mkdev(int ai, struct hfidd_acs *p_acs)
+{
+ char dname[128];
+ int rc = 0;
+
+ sprintf(dname, "%s%d", HFIDD_DEV_NAME, ai);
+
+ hfidd_class_dev[ai] = device_create(hfidd_global.class,
+ NULL, MKDEV(MAJOR(hfidd_dev), ai),
+ (void *)p_acs, (char *)dname);
+
+ if (IS_ERR(hfidd_class_dev[ai])) {
+ rc = PTR_ERR(hfidd_class_dev[ai]);
+ printk(KERN_ERR "%s: hfidd_mkdev: device_create for ai=%d fail"
+ " rc = %d\n", dname, ai, rc);
+ return rc;
+ }
+
+ if (ai == MAX_HFIS)
+ return 0;
+
+ p_acs->hfidd_dev = hfidd_class_dev[ai];
+ return rc;
+}
+
+/* delete the hfi device, /dev/hfi* files and sysclass files */
+static void hfidd_rmdev(int ai)
+{
+ device_destroy(hfidd_global.class, MKDEV(MAJOR(hfidd_dev), ai));
+}
+
/* Destroy the HFI class */
static inline void hfidd_destroy_class(void)
{
@@ -128,6 +161,8 @@ static void hfidd_destroy_devices(void)
hfidd_global.p_acs[i] = NULL;
hfidd_global.acs_cnt--;
}
+ for (i = 0; i <= MAX_HFIS; i++)
+ hfidd_rmdev(i);
}
/*
@@ -155,6 +190,23 @@ static int hfidd_create_devices(void)
}
hfidd_global.acs_cnt++;
}
+
+ for (i = 0; i <= MAX_HFIS; i++) {
+ rc = hfidd_mkdev(i, hfidd_global.p_acs[i]);
+ if (rc) {
+ for (j = 0; j < i; j++)
+ hfidd_rmdev(j);
+ goto hfidd_create_devices_error0;
+ }
+ }
+ return 0;
+
+hfidd_create_devices_error0:
+ for (i = 0; i < MAX_HFIS; i++) {
+ hfidd_free_adapter(hfidd_global.p_acs[i]);
+ hfidd_global.p_acs[i] = NULL;
+ hfidd_global.acs_cnt--;
+ }
return rc;
}
diff --git a/include/linux/hfi/hfidd_internal.h b/include/linux/hfi/hfidd_internal.h
index 66765a5..956e6b2 100644
--- a/include/linux/hfi/hfidd_internal.h
+++ b/include/linux/hfi/hfidd_internal.h
@@ -54,6 +54,7 @@ struct hfidd_acs {
unsigned int index;
unsigned int acs_cnt;
unsigned int state;
+ struct device *hfidd_dev;
};
/* DD global */
--
1.7.3.5
^ permalink raw reply related
* [PATCH v4 04/27] HFI: Find HFI devices in the device tree
From: dykmanj @ 2011-04-25 21:23 UTC (permalink / raw)
To: netdev
Cc: Jim Dykman, Piyush Chaudhary, Fu-Chung Chang, William S. Cadden,
Wen C. Chen, Scot Sakolish, Jian Xiao, Carol L. Soto,
Sarah J. Sheppard
In-Reply-To: <1303766647-30156-1-git-send-email-dykmanj@linux.vnet.ibm.com>
From: Jim Dykman <dykmanj@linux.vnet.ibm.com>
Signed-off-by: Piyush Chaudhary <piyushc@linux.vnet.ibm.com>
Signed-off-by: Jim Dykman <dykmanj@linux.vnet.ibm.com>
Signed-off-by: Fu-Chung Chang <fcchang@linux.vnet.ibm.com>
Signed-off-by: William S. Cadden <wscadden@linux.vnet.ibm.com>
Signed-off-by: Wen C. Chen <winstonc@linux.vnet.ibm.com>
Signed-off-by: Scot Sakolish <sakolish@linux.vnet.ibm.com>
Signed-off-by: Jian Xiao <jian@linux.vnet.ibm.com>
Signed-off-by: Carol L. Soto <clsoto@linux.vnet.ibm.com>
Signed-off-by: Sarah J. Sheppard <sjsheppa@linux.vnet.ibm.com>
---
drivers/net/hfi/core/hfidd_adpt.c | 10 +++
drivers/net/hfi/core/hfidd_init.c | 108 ++++++++++++++++++++++++++++++++++++
drivers/net/hfi/core/hfidd_proto.h | 1 +
include/linux/hfi/hfidd_adpt.h | 5 ++
include/linux/hfi/hfidd_client.h | 3 +
include/linux/hfi/hfidd_internal.h | 12 ++++
6 files changed, 139 insertions(+), 0 deletions(-)
diff --git a/drivers/net/hfi/core/hfidd_adpt.c b/drivers/net/hfi/core/hfidd_adpt.c
index ec6a053..f309a02 100644
--- a/drivers/net/hfi/core/hfidd_adpt.c
+++ b/drivers/net/hfi/core/hfidd_adpt.c
@@ -36,6 +36,7 @@
int hfidd_alloc_adapter(struct hfidd_acs **adpt, dev_t devno, void *uiop)
{
+ int ret = 0;
struct hfidd_acs *p_acs = NULL;
p_acs = kzalloc(sizeof(*p_acs), GFP_KERNEL);
@@ -48,8 +49,17 @@ int hfidd_alloc_adapter(struct hfidd_acs **adpt, dev_t devno, void *uiop)
snprintf(p_acs->name, HFI_DEVICE_NAME_MAX,
"%s%d", HFIDD_DEV_NAME, p_acs->index);
+ ret = hfidd_init_adapter(p_acs, uiop);
+ if (ret)
+ goto err_exit0;
+
*adpt = p_acs;
return 0;
+
+err_exit0:
+ kfree(p_acs);
+ p_acs = NULL;
+ return ret;
}
void hfidd_free_adapter(struct hfidd_acs *p_acs)
diff --git a/drivers/net/hfi/core/hfidd_init.c b/drivers/net/hfi/core/hfidd_init.c
index 40d5aaf..d181d97 100644
--- a/drivers/net/hfi/core/hfidd_init.c
+++ b/drivers/net/hfi/core/hfidd_init.c
@@ -33,6 +33,7 @@
#include <linux/module.h>
#include <linux/init.h>
#include <linux/device.h>
+#include <linux/of.h>
#include <linux/hfi/hfidd_internal.h>
#include "hfidd_proto.h"
@@ -103,6 +104,113 @@ static void hfidd_rmdev(int ai)
device_destroy(hfidd_global.class, MKDEV(MAJOR(hfidd_dev), ai));
}
+/*
+ * Read the hfi device tree attributes and
+ * fill the hfidd_dds structure to be used by the driver
+ */
+static int hfidd_dds_init(struct hfidd_acs *p_acs, struct hfidd_dds *pdds)
+{
+ struct device_node *node;
+ struct device_node *child_node = NULL;
+ unsigned long long *lp;
+ int *p;
+ unsigned char octant;
+ unsigned char id;
+ int found = 0;
+
+ node = of_find_node_by_name(NULL, "hfi-iohub");
+ if (!node) {
+ printk(KERN_ERR "%s: hfidd_dds_init: of_find_node_by_name"
+ " 'hfi-iohub' failed\n", p_acs->name);
+ return -EINVAL;
+ }
+
+ lp = (unsigned long long *)of_get_property(node, "reg", NULL);
+ if (!lp) {
+ printk(KERN_ERR "%s: hfidd_dds_init: of_get_property"
+ " 'hfi-iohub/reg' failed\n", p_acs->name);
+ return -EINVAL;
+ }
+ pdds->torr_id = *lp;
+
+ lp = (unsigned long long *)of_get_property(node,
+ "ibm,fw-ec-level", NULL);
+ if (!lp) {
+ printk(KERN_ERR "%s: hfidd_dds_init: of_get_property"
+ " 'ibm,fw-ec-level' failed\n", p_acs->name);
+ return -EINVAL;
+ }
+ pdds->fw_ec_level = *lp;
+
+ octant = (node->full_name[strlen(node->full_name) - 1] - '0');
+ if (octant > HFI_MAX_OCTANT) {
+ printk(KERN_ERR "%s: hfidd_dds_init: invalid hfi-iohub octant"
+ " '%s'\n", node->full_name, p_acs->name);
+ return -EINVAL;
+ }
+
+ id = ((octant << HFI_SHIFT_OCTANT) | p_acs->index);
+
+ while ((child_node = of_get_next_child(node, child_node))) {
+ p = (int *)of_get_property(child_node, "reg", NULL);
+ if (!p) {
+ printk(KERN_ERR "%s: hfidd_dds_init: of_get_property "
+ "'reg' failed\n", p_acs->name);
+ return -EINVAL;
+ }
+
+ if (id == *p) {
+ pdds->hfi_id = *p;
+ found = 1;
+ break;
+ }
+ }
+
+ if (found == 0) {
+ printk(KERN_ERR "%s: hfidd_dds_init: can not find child\n",
+ p_acs->name);
+ return -EINVAL;
+ }
+
+ lp = (unsigned long long *)of_get_property(child_node,
+ "ibm,hfi-windows", NULL);
+ if (!lp) {
+ printk(KERN_ERR "%s: hfidd_dds_init: of_get_property"
+ " 'ibm,hfi-windows' failed\n", p_acs->name);
+ return -EINVAL;
+ }
+
+ pdds->window_num = (int) (*lp >> HFI_WNUM_SHIFT);
+ pdds->window_start = (int) *lp;
+
+ if (pdds->window_num > MAX_WIN_PER_HFI) {
+ printk(KERN_ERR "%s: hfidd_dds_init: Max windows exceeded,"
+ " windows=%d\n", p_acs->name, pdds->window_num);
+ return -EINVAL;
+ }
+
+ lp = (unsigned long long *)of_get_property(child_node,
+ "ibm,hfi-misc-user-base-addr", NULL);
+ if (!lp) {
+ printk(KERN_ERR "%s: hfidd_dds_init: of_get_property"
+ " 'ibm,hfi-misc-user-base-addr' failed\n", p_acs->name);
+ return -EINVAL;
+ }
+ pdds->misc_base_address = *lp;
+
+ return 0;
+}
+
+/* Initialize adapter structure */
+int hfidd_init_adapter(struct hfidd_acs *p_acs, void *uiop)
+{
+ int rc = 0;
+
+ rc = hfidd_dds_init(p_acs, &(p_acs->dds));
+ p_acs->dds.num_d_windows = HFI_DYN_WINS_DEFAULT;
+ return rc;
+}
+
/* Destroy the HFI class */
static inline void hfidd_destroy_class(void)
{
diff --git a/drivers/net/hfi/core/hfidd_proto.h b/drivers/net/hfi/core/hfidd_proto.h
index 01a5ba2..e2ed4c9 100644
--- a/drivers/net/hfi/core/hfidd_proto.h
+++ b/drivers/net/hfi/core/hfidd_proto.h
@@ -35,5 +35,6 @@
int hfidd_alloc_adapter(struct hfidd_acs **adpt, dev_t, void *uiop);
void hfidd_free_adapter(struct hfidd_acs *p_acs);
+int hfidd_init_adapter(struct hfidd_acs *p_acs, void *uiop);
#endif
diff --git a/include/linux/hfi/hfidd_adpt.h b/include/linux/hfi/hfidd_adpt.h
index 6b1432d..e3271e9 100644
--- a/include/linux/hfi/hfidd_adpt.h
+++ b/include/linux/hfi/hfidd_adpt.h
@@ -36,6 +36,11 @@
#include <linux/hfi/hfidd_client.h>
+#define HFI_WNUM_SHIFT 32
+#define HFI_CAUNUM_SHIFT 32
+#define HFI_SHIFT_OCTANT 3
+#define HFI_MAX_OCTANT 7
+
/* Adpt state */
#define HFI_INVALID 0
#define HFI_AVAIL 1
diff --git a/include/linux/hfi/hfidd_client.h b/include/linux/hfi/hfidd_client.h
index b738f4b..28f1693 100644
--- a/include/linux/hfi/hfidd_client.h
+++ b/include/linux/hfi/hfidd_client.h
@@ -36,5 +36,8 @@
#define MAX_TORRENTS 1
#define MAX_HFI_PER_TORRENT 2
#define MAX_HFIS (MAX_TORRENTS * MAX_HFI_PER_TORRENT)
+#define MAX_WIN_PER_HFI 256
+
+#define HFI_DYN_WINS_DEFAULT 32
#endif /* _HFIDD_CLIENT_H_ */
diff --git a/include/linux/hfi/hfidd_internal.h b/include/linux/hfi/hfidd_internal.h
index 956e6b2..78a5763 100644
--- a/include/linux/hfi/hfidd_internal.h
+++ b/include/linux/hfi/hfidd_internal.h
@@ -46,6 +46,17 @@
#define HFIDD_DEV_NAME "hfi"
#define HFIDD_CLASS_NAME "hfi"
+struct hfidd_dds {
+ unsigned int version; /* HFI adapter type */
+ unsigned long long misc_base_address; /* Misc user base address */
+ int window_start; /* window start for this HFI */
+ int window_num; /* window count for this HFI */
+ unsigned int num_d_windows; /* number of dynamic windows */
+ unsigned long long torr_id; /* torrent chip id */
+ unsigned int hfi_id; /* HFI Unit Id */
+ unsigned long long fw_ec_level; /* Firmware Level */
+};
+
#define HFI_DEVICE_NAME_MAX 8
/* hfi global */
struct hfidd_acs {
@@ -55,6 +66,7 @@ struct hfidd_acs {
unsigned int acs_cnt;
unsigned int state;
struct device *hfidd_dev;
+ struct hfidd_dds dds;
};
/* DD global */
--
1.7.3.5
^ permalink raw reply related
* [PATCH v4 02/27] HFI: Add HFI adapter control structure
From: dykmanj @ 2011-04-25 21:23 UTC (permalink / raw)
To: netdev
Cc: Jim Dykman, Piyush Chaudhary, Fu-Chung Chang, William S. Cadden,
Wen C. Chen, Scot Sakolish, Jian Xiao, Carol L. Soto,
Sarah J. Sheppard
In-Reply-To: <1303766647-30156-1-git-send-email-dykmanj@linux.vnet.ibm.com>
From: Jim Dykman <dykmanj@linux.vnet.ibm.com>
Alloc/free of hfidd_acs to track the state of each HFI
Signed-off-by: Piyush Chaudhary <piyushc@linux.vnet.ibm.com>
Signed-off-by: Jim Dykman <dykmanj@linux.vnet.ibm.com>
Signed-off-by: Fu-Chung Chang <fcchang@linux.vnet.ibm.com>
Signed-off-by: William S. Cadden <wscadden@linux.vnet.ibm.com>
Signed-off-by: Wen C. Chen <winstonc@linux.vnet.ibm.com>
Signed-off-by: Scot Sakolish <sakolish@linux.vnet.ibm.com>
Signed-off-by: Jian Xiao <jian@linux.vnet.ibm.com>
Signed-off-by: Carol L. Soto <clsoto@linux.vnet.ibm.com>
Signed-off-by: Sarah J. Sheppard <sjsheppa@linux.vnet.ibm.com>
---
drivers/net/hfi/core/Makefile | 3 +-
drivers/net/hfi/core/hfidd_adpt.c | 58 ++++++++++++++++++++++++++++++++++++
drivers/net/hfi/core/hfidd_init.c | 55 ++++++++++++++++++++++++++++++++++
drivers/net/hfi/core/hfidd_proto.h | 39 ++++++++++++++++++++++++
include/linux/hfi/hfidd_adpt.h | 45 ++++++++++++++++++++++++++++
include/linux/hfi/hfidd_internal.h | 14 ++++++++
6 files changed, 213 insertions(+), 1 deletions(-)
create mode 100644 drivers/net/hfi/core/hfidd_adpt.c
create mode 100644 drivers/net/hfi/core/hfidd_proto.h
create mode 100644 include/linux/hfi/hfidd_adpt.h
diff --git a/drivers/net/hfi/core/Makefile b/drivers/net/hfi/core/Makefile
index 80790c6..6fe4e60 100644
--- a/drivers/net/hfi/core/Makefile
+++ b/drivers/net/hfi/core/Makefile
@@ -1,5 +1,6 @@
#
# Makefile for the HFI device driver for IBM eServer System p
#
-hfi_core-objs:= hfidd_init.o
+hfi_core-objs:= hfidd_adpt.o \
+ hfidd_init.o
obj-$(CONFIG_HFI) += hfi_core.o
diff --git a/drivers/net/hfi/core/hfidd_adpt.c b/drivers/net/hfi/core/hfidd_adpt.c
new file mode 100644
index 0000000..ec6a053
--- /dev/null
+++ b/drivers/net/hfi/core/hfidd_adpt.c
@@ -0,0 +1,58 @@
+/*
+ * hfidd_adpt.c
+ *
+ * HFI device driver for IBM System p
+ *
+ * Authors:
+ * Fu-Chung Chang <fcchang@linux.vnet.ibm.com>
+ * William S. Cadden <wscadden@linux.vnet.ibm.com>
+ * Wen C. Chen <winstonc@linux.vnet.ibm.com>
+ * Scot Sakolish <sakolish@linux.vnet.ibm.com>
+ * Jian Xiao <jian@linux.vnet.ibm.com>
+ * Carol L. Soto <clsoto@linux.vnet.ibm.com>
+ * Sarah J. Sheppard <sjsheppa@linux.vnet.ibm.com>
+ *
+ * (C) Copyright IBM Corp. 2010
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include <linux/hfi/hfidd_internal.h>
+#include "hfidd_proto.h"
+
+int hfidd_alloc_adapter(struct hfidd_acs **adpt, dev_t devno, void *uiop)
+{
+
+ struct hfidd_acs *p_acs = NULL;
+
+ p_acs = kzalloc(sizeof(*p_acs), GFP_KERNEL);
+ if (p_acs == NULL)
+ return -ENOMEM;
+
+ p_acs->dev_num = devno;
+ p_acs->index = MINOR(devno);
+ p_acs->state = HFI_INVALID;
+ snprintf(p_acs->name, HFI_DEVICE_NAME_MAX,
+ "%s%d", HFIDD_DEV_NAME, p_acs->index);
+
+ *adpt = p_acs;
+ return 0;
+}
+
+void hfidd_free_adapter(struct hfidd_acs *p_acs)
+{
+ kfree(p_acs);
+}
diff --git a/drivers/net/hfi/core/hfidd_init.c b/drivers/net/hfi/core/hfidd_init.c
index 9498faf..61ed559 100644
--- a/drivers/net/hfi/core/hfidd_init.c
+++ b/drivers/net/hfi/core/hfidd_init.c
@@ -35,6 +35,7 @@
#include <linux/device.h>
#include <linux/hfi/hfidd_internal.h>
+#include "hfidd_proto.h"
MODULE_VERSION("1.0");
MODULE_DESCRIPTION("Device Driver for IBM eServer HFI for IBM System p");
@@ -117,10 +118,52 @@ hfidd_create_class_error1:
return rc;
}
+/* Free adapter resources and the devicese */
+static void hfidd_destroy_devices(void)
+{
+ int i;
+
+ for (i = 0; i < MAX_HFIS; i++) {
+ hfidd_free_adapter(hfidd_global.p_acs[i]);
+ hfidd_global.p_acs[i] = NULL;
+ hfidd_global.acs_cnt--;
+ }
+}
+
+/*
+ * Create the adapter structure, allocate resources and create
+ * the hfi devices
+ */
+static int hfidd_create_devices(void)
+{
+ int i, j;
+ int rc = 0;
+
+ for (i = 0; i < MAX_HFIS; i++) {
+ rc = hfidd_alloc_adapter(&(hfidd_global.p_acs[i]),
+ MKDEV(MAJOR(hfidd_dev), i), NULL);
+ if (rc) {
+ printk(KERN_ERR "%s: hfidd_create_devices: "
+ "hfidd_alloc_adapter fail rc = %d\n",
+ HFIDD_DEV_NAME, rc);
+ for (j = 0; j < i; j++) {
+ hfidd_free_adapter(hfidd_global.p_acs[j]);
+ hfidd_global.p_acs[j] = NULL;
+ hfidd_global.acs_cnt--;
+ }
+ return rc;
+ }
+ hfidd_global.acs_cnt++;
+ }
+ return rc;
+}
+
static int __init hfidd_mod_init(void)
{
int rc = 0;
+ hfidd_global.acs_cnt = 0;
+
rc = hfidd_create_class();
if (rc < 0) {
printk(KERN_ERR "%s: hfidd_mod_init: hfidd_create_class failed"
@@ -128,12 +171,24 @@ static int __init hfidd_mod_init(void)
return rc;
}
+ rc = hfidd_create_devices();
+ if (rc < 0) {
+ printk(KERN_ERR "%s: hfidd_mod_init: hfidd_create_devices"
+ " failed rc = %d\n", HFIDD_DEV_NAME, rc);
+ goto error1;
+ }
+
printk(KERN_INFO "IBM hfi device driver loaded sucessfully\n");
return 0;
+
+error1:
+ hfidd_destroy_class();
+ return rc;
}
static void __exit hfidd_mod_exit(void)
{
+ hfidd_destroy_devices();
hfidd_destroy_class();
}
diff --git a/drivers/net/hfi/core/hfidd_proto.h b/drivers/net/hfi/core/hfidd_proto.h
new file mode 100644
index 0000000..01a5ba2
--- /dev/null
+++ b/drivers/net/hfi/core/hfidd_proto.h
@@ -0,0 +1,39 @@
+/*
+ * hfidd_proto.h
+ *
+ * HFI device driver for IBM System p
+ *
+ * Authors:
+ * Fu-Chung Chang <fcchang@linux.vnet.ibm.com>
+ * William S. Cadden <wscadden@linux.vnet.ibm.com>
+ * Wen C. Chen <winstonc@linux.vnet.ibm.com>
+ * Scot Sakolish <sakolish@linux.vnet.ibm.com>
+ * Jian Xiao <jian@linux.vnet.ibm.com>
+ * Carol L. Soto <clsoto@linux.vnet.ibm.com>
+ * Sarah J. Sheppard <sjsheppa@linux.vnet.ibm.com)
+ *
+ * Copyright IBM Corp. 2010
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#ifndef _HFIDD_PROTO_H_
+#define _HFIDD_PROTO_H_
+
+int hfidd_alloc_adapter(struct hfidd_acs **adpt, dev_t, void *uiop);
+void hfidd_free_adapter(struct hfidd_acs *p_acs);
+
+#endif
diff --git a/include/linux/hfi/hfidd_adpt.h b/include/linux/hfi/hfidd_adpt.h
new file mode 100644
index 0000000..6b1432d
--- /dev/null
+++ b/include/linux/hfi/hfidd_adpt.h
@@ -0,0 +1,45 @@
+/*
+ * hfidd_adpt.h
+ *
+ * HFI device driver for IBM System p
+ *
+ * Authors:
+ * Fu-Chung Chang <fcchang@linux.vnet.ibm.com>
+ * William S. Cadden <wscadden@linux.vnet.ibm.com>
+ * Wen C. Chen <winstonc@linux.vnet.ibm.com>
+ * Scot Sakolish <sakolish@linux.vnet.ibm.com>
+ * Jian Xiao <jian@linux.vnet.ibm.com>
+ * Carol L. Soto <clsoto@linux.vnet.ibm.com>
+ * Sarah J. Sheppard <sjsheppa@linux.vnet.ibm.com>
+ *
+ * (C) Copyright IBM Corp. 2010
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#ifndef _HFIDD_ADPT_H_
+#define _HFIDD_ADPT_H_
+
+#include <linux/hfi/hfidd_client.h>
+
+
+/* Adpt state */
+#define HFI_INVALID 0
+#define HFI_AVAIL 1
+#define HFI_GOING_UNAVAIL 2
+#define HFI_UNAVAIL 3
+
+#endif /* _HFIDD_ADPT_H_ */
diff --git a/include/linux/hfi/hfidd_internal.h b/include/linux/hfi/hfidd_internal.h
index f5de1bb..66765a5 100644
--- a/include/linux/hfi/hfidd_internal.h
+++ b/include/linux/hfi/hfidd_internal.h
@@ -38,16 +38,30 @@
#include <linux/cdev.h>
#include <linux/init.h>
#include <linux/kernel.h>
+#include <linux/slab.h>
#include <linux/hfi/hfidd_client.h>
+#include <linux/hfi/hfidd_adpt.h>
#define HFIDD_DEV_NAME "hfi"
#define HFIDD_CLASS_NAME "hfi"
+#define HFI_DEVICE_NAME_MAX 8
+/* hfi global */
+struct hfidd_acs {
+ dev_t dev_num;
+ char name[HFI_DEVICE_NAME_MAX];
+ unsigned int index;
+ unsigned int acs_cnt;
+ unsigned int state;
+};
+
/* DD global */
struct hfidd_global {
struct cdev cdev;
struct class *class;
+ int acs_cnt;
+ struct hfidd_acs *p_acs[MAX_HFIS];
};
#endif
--
1.7.3.5
^ permalink raw reply related
* [PATCH v4 05/27] HFI: The first few HFI-specific hypervisor calls
From: dykmanj @ 2011-04-25 21:23 UTC (permalink / raw)
To: netdev
Cc: Jim Dykman, Piyush Chaudhary, Fu-Chung Chang, William S. Cadden,
Wen C. Chen, Scot Sakolish, Jian Xiao, Carol L. Soto,
Sarah J. Sheppard
In-Reply-To: <1303766647-30156-1-git-send-email-dykmanj@linux.vnet.ibm.com>
From: Jim Dykman <dykmanj@linux.vnet.ibm.com>
H_HFI_START_INTERFACE Notifies the hypervisor that a new instance of the DD is
starting, and any leftover state should be considered stale.
H_HFI_STOP_INTERFACE tells the hypervisor that the DD is unloading, and to
clean up any activity related to this DD instance.
H_HFI_QUERY_INTERFACE lets us get info about the HFIs that is not in the
device tree.
Signed-off-by: Piyush Chaudhary <piyushc@linux.vnet.ibm.com>
Signed-off-by: Jim Dykman <dykmanj@linux.vnet.ibm.com>
Signed-off-by: Fu-Chung Chang <fcchang@linux.vnet.ibm.com>
Signed-off-by: William S. Cadden <wscadden@linux.vnet.ibm.com>
Signed-off-by: Wen C. Chen <winstonc@linux.vnet.ibm.com>
Signed-off-by: Scot Sakolish <sakolish@linux.vnet.ibm.com>
Signed-off-by: Jian Xiao <jian@linux.vnet.ibm.com>
Signed-off-by: Carol L. Soto <clsoto@linux.vnet.ibm.com>
Signed-off-by: Sarah J. Sheppard <sjsheppa@linux.vnet.ibm.com>
---
drivers/net/hfi/core/Makefile | 3 +-
drivers/net/hfi/core/hfidd_adpt.c | 139 +++++++++++++++++++++++++++++++++++
drivers/net/hfi/core/hfidd_hcalls.c | 90 ++++++++++++++++++++++
drivers/net/hfi/core/hfidd_proto.h | 12 +++
include/linux/hfi/hfidd_client.h | 8 ++
include/linux/hfi/hfidd_hcalls.h | 58 +++++++++++++++
include/linux/hfi/hfidd_internal.h | 7 ++-
7 files changed, 315 insertions(+), 2 deletions(-)
create mode 100644 drivers/net/hfi/core/hfidd_hcalls.c
create mode 100644 include/linux/hfi/hfidd_hcalls.h
diff --git a/drivers/net/hfi/core/Makefile b/drivers/net/hfi/core/Makefile
index 6fe4e60..4e6cbd6 100644
--- a/drivers/net/hfi/core/Makefile
+++ b/drivers/net/hfi/core/Makefile
@@ -2,5 +2,6 @@
# Makefile for the HFI device driver for IBM eServer System p
#
hfi_core-objs:= hfidd_adpt.o \
- hfidd_init.o
+ hfidd_init.o \
+ hfidd_hcalls.o
obj-$(CONFIG_HFI) += hfi_core.o
diff --git a/drivers/net/hfi/core/hfidd_adpt.c b/drivers/net/hfi/core/hfidd_adpt.c
index f309a02..fd4a0cb 100644
--- a/drivers/net/hfi/core/hfidd_adpt.c
+++ b/drivers/net/hfi/core/hfidd_adpt.c
@@ -33,6 +33,18 @@
#include <linux/hfi/hfidd_internal.h>
#include "hfidd_proto.h"
+#define HFIDD_TIME_AGE (10 * HZ)
+
+int hfidd_age_hcall(u64 time_start)
+{
+ u64 timestamp = get_jiffies_64();
+
+ if ((timestamp - time_start) > HFIDD_TIME_AGE)
+ return 1;
+ else
+ return 0;
+}
+
int hfidd_alloc_adapter(struct hfidd_acs **adpt, dev_t devno, void *uiop)
{
@@ -66,3 +78,130 @@ void hfidd_free_adapter(struct hfidd_acs *p_acs)
{
kfree(p_acs);
}
+
+/* Allocate the page for the HCALL */
+int hfidd_get_phyp_page(struct hfidd_acs *p_acs, caddr_t *page, caddr_t *laddr,
+ int size)
+{
+ *page = (caddr_t)__get_free_pages(GFP_KERNEL, get_order(size));
+ if (*page == NULL) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_get_phyp_page: __get_free_pages failed\n");
+ return -ENOMEM;
+ }
+
+ /* translate virtual to logical address */
+ *laddr = (caddr_t)__pa((caddr_t) *page);
+ memset(*page, 0, size);
+ return 0;
+}
+
+/* Release the page allocated for the HCALL */
+inline void hfidd_release_phyp_page(caddr_t page, int size)
+{
+ free_pages((unsigned long)page, get_order(size));
+}
+
+int hfidd_query_interface(struct hfidd_acs *p_acs, unsigned int subtype,
+ unsigned int hfi_id, unsigned long long *state)
+{
+ long long hvrc;
+ int rc = 0;
+ struct hfi_query_interface *query_p;
+ caddr_t laddr = NULL;
+
+ if (subtype != COMP_QUERY && subtype != EEH_QUERY) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_query_interface: subtype not supported, %d\n",
+ subtype);
+ return -EINVAL;
+ }
+
+ if (subtype == COMP_QUERY) {
+ /* Allocate the page for the HCALL */
+ rc = hfidd_get_phyp_page(p_acs, (caddr_t *)&query_p, &laddr,
+ PAGE_SIZE_4K);
+ if (rc) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_query_interface: hfidd_get_phyp_page "
+ "failed\n");
+ return -ENOMEM;
+ }
+ }
+
+ hvrc = hfi_hquery_interface(hfi_id, subtype,
+ (unsigned long long)laddr, state);
+ if (hvrc != H_SUCCESS) {
+ rc = -EPERM;
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_query_interface: failed, state 0x%llx "
+ "hvrc 0x%llx\n", *state, hvrc);
+ goto query1;
+ }
+
+ if (subtype == COMP_QUERY) {
+ if (*state == ACTIVE) {
+ if (p_acs->state != HFI_AVAIL) {
+ p_acs->isr = query_p->local_node_id;
+ p_acs->state = HFI_AVAIL;
+ }
+ } else {
+ p_acs->state = HFI_UNAVAIL;
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_query_interface: Bad state %lld, "
+ "return ENODEV\n", *state);
+ rc = -EIO;
+ }
+ }
+
+query1:
+ if (subtype == COMP_QUERY)
+ hfidd_release_phyp_page((caddr_t)query_p, PAGE_SIZE_4K);
+ dev_printk(KERN_INFO, p_acs->hfidd_dev,
+ "hfidd_query_interface: return rc %d\n", rc);
+ return rc;
+}
+
+int hfidd_start_interface(struct hfidd_acs *p_acs)
+{
+ long long hvrc = 0;
+ int rc = 0;
+ u64 start_time = get_jiffies_64();
+
+ while (1) {
+ hvrc = hfi_start_interface(p_acs->dds.hfi_id);
+ if (hvrc != H_BUSY)
+ break;
+ if (hfidd_age_hcall(start_time))
+ break;
+ }
+ if (hvrc != H_SUCCESS) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_start_interface: HFI_START_INTERFACE failed "
+ "hvrc 0x%llx\n", hvrc);
+ rc = -EPERM;
+ }
+ return rc;
+}
+
+int hfidd_stop_interface(struct hfidd_acs *p_acs, unsigned int hfi_id)
+{
+ long long hvrc = 0;
+ int rc = 0;
+ u64 start_time = get_jiffies_64();
+
+ while (1) {
+ hvrc = hfi_stop_interface(hfi_id);
+ if (hvrc != H_BUSY)
+ break;
+ if (hfidd_age_hcall(start_time))
+ break;
+ }
+ if (hvrc != H_SUCCESS) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_stop_interface: HFI_STOP_INTERFACE failed "
+ "hvrc 0x%llx\n", hvrc);
+ rc = -EPERM;
+ }
+ return rc;
+}
diff --git a/drivers/net/hfi/core/hfidd_hcalls.c b/drivers/net/hfi/core/hfidd_hcalls.c
new file mode 100644
index 0000000..84467b3
--- /dev/null
+++ b/drivers/net/hfi/core/hfidd_hcalls.c
@@ -0,0 +1,90 @@
+/*
+ * hfidd_hcalls.c
+ *
+ * HFI device driver for IBM System p
+ *
+ * Authors:
+ * Fu-Chung Chang <fcchang@linux.vnet.ibm.com>
+ * William S. Cadden <wscadden@linux.vnet.ibm.com>
+ * Wen C. Chen <winstonc@linux.vnet.ibm.com>
+ * Scot Sakolish <sakolish@linux.vnet.ibm.com>
+ * Jian Xiao <jian@linux.vnet.ibm.com>
+ * Carol L. Soto <clsoto@linux.vnet.ibm.com>
+ * Sarah J. Sheppard <sjsheppa@linux.vnet.ibm.com>
+ *
+ * (C) Copyright IBM Corp. 2010
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include <linux/hfi/hfidd_internal.h>
+#include "hfidd_proto.h"
+
+static inline long long h_hfi_start_interface(int token,
+ u64 HFI_chip_ID)
+{
+ return plpar_hcall_norets(token, HFI_chip_ID);
+}
+
+static inline long long h_hfi_stop_interface(int token,
+ u64 HFI_chip_ID)
+{
+ return plpar_hcall_norets(token, HFI_chip_ID);
+}
+
+static inline long long h_hfi_query_interface(int token,
+ u64 HFI_chip_ID,
+ u64 type,
+ u64 output_page_ptr,
+ u64 *state)
+{
+ long long rc;
+ u64 hyp_outputs[PLPAR_HCALL_BUFSIZE];
+
+ rc = plpar_hcall(token, (unsigned long *)hyp_outputs, HFI_chip_ID, type,
+ output_page_ptr);
+ *state = hyp_outputs[0]; /* 1st ret value */
+
+ return rc;
+}
+
+long long hfi_hquery_interface(u64 unit_id, u64 subtype,
+ u64 query_p, u64 *state)
+{
+ long long hvrc;
+
+ hvrc = h_hfi_query_interface(H_HFI_QUERY_INTERFACE,
+ unit_id,
+ subtype,
+ query_p,
+ state);
+ return hvrc;
+}
+
+long long hfi_start_interface(u64 unit_id)
+{
+ return h_hfi_start_interface(H_HFI_START_INTERFACE,
+ unit_id);
+}
+
+long long hfi_stop_interface(u64 unit_id)
+{
+ long long hvrc;
+
+ hvrc = h_hfi_stop_interface(H_HFI_STOP_INTERFACE,
+ unit_id);
+ return hvrc;
+}
diff --git a/drivers/net/hfi/core/hfidd_proto.h b/drivers/net/hfi/core/hfidd_proto.h
index e2ed4c9..6ec9245 100644
--- a/drivers/net/hfi/core/hfidd_proto.h
+++ b/drivers/net/hfi/core/hfidd_proto.h
@@ -36,5 +36,17 @@
int hfidd_alloc_adapter(struct hfidd_acs **adpt, dev_t, void *uiop);
void hfidd_free_adapter(struct hfidd_acs *p_acs);
int hfidd_init_adapter(struct hfidd_acs *p_acs, void *uiop);
+int hfidd_age_hcall(u64 time_start);
+int hfidd_get_phyp_page(struct hfidd_acs *p_acs, caddr_t *page,
+ caddr_t *laddr, int size);
+void hfidd_release_phyp_page(caddr_t page, int size);
+int hfidd_query_interface(struct hfidd_acs *p_acs, unsigned int subtype,
+ unsigned int hfi_id, unsigned long long *state);
+int hfidd_start_interface(struct hfidd_acs *p_acs);
+int hfidd_stop_interface(struct hfidd_acs *p_acs, unsigned int hfi_id);
+long long hfi_hquery_interface(u64 unit_id, u64 subtype, u64 query_p,
+ u64 *state);
+long long hfi_start_interface(u64 unit_id);
+long long hfi_stop_interface(u64 unit_id);
#endif
diff --git a/include/linux/hfi/hfidd_client.h b/include/linux/hfi/hfidd_client.h
index 28f1693..2714a27 100644
--- a/include/linux/hfi/hfidd_client.h
+++ b/include/linux/hfi/hfidd_client.h
@@ -40,4 +40,12 @@
#define HFI_DYN_WINS_DEFAULT 32
+#define PAGE_SIZE_4K 0x1000
+#define PAGE_SIZE_64K 0x10000
+#define PAGE_SIZE_1M 0x100000
+#define PAGE_SIZE_16M 0x1000000
+#define PAGE_SIZE_256M 0x10000000
+#define PAGE_SIZE_4G 0x100000000
+#define PAGE_SIZE_16G 0x400000000
+
#endif /* _HFIDD_CLIENT_H_ */
diff --git a/include/linux/hfi/hfidd_hcalls.h b/include/linux/hfi/hfidd_hcalls.h
new file mode 100644
index 0000000..5349e9e
--- /dev/null
+++ b/include/linux/hfi/hfidd_hcalls.h
@@ -0,0 +1,58 @@
+/*
+ * hfidd_hcalls.h
+ *
+ * HFI device driver for IBM System p
+ *
+ * Authors:
+ * Fu-Chung Chang <fcchang@linux.vnet.ibm.com>
+ * William S. Cadden <wscadden@linux.vnet.ibm.com>
+ * Wen C. Chen <winstonc@linux.vnet.ibm.com>
+ * Scot Sakolish <sakolish@linux.vnet.ibm.com>
+ * Jian Xiao <jian@linux.vnet.ibm.com>
+ * Carol L. Soto <clsoto@linux.vnet.ibm.com>
+ * Sarah J. Sheppard <sjsheppa@linux.vnet.ibm.com>
+ *
+ * (C) Copyright IBM Corp. 2010
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#ifndef _HFIDD_HCALLS_H_
+#define _HFIDD_HCALLS_H_
+
+#include <asm/hvcall.h>
+
+/* Token IDs */
+#define H_HFI_START_INTERFACE 0xF000
+#define H_HFI_QUERY_INTERFACE 0xF004
+#define H_HFI_STOP_INTERFACE 0xF008
+
+#define EEH_QUERY 1
+#define COMP_QUERY 2
+
+/* States of Query interface */
+#define NOT_READY 0
+#define NOT_STARTED 1
+#define ACTIVE 2
+#define CLOSING 3
+#define ERROR 101
+
+struct hfi_query_interface {
+ unsigned long long hypervisor_capabilities;
+ unsigned int local_node_id;
+};
+
+#endif /* _HFIDD_HCALLS_H_ */
diff --git a/include/linux/hfi/hfidd_internal.h b/include/linux/hfi/hfidd_internal.h
index 78a5763..c7c67ca 100644
--- a/include/linux/hfi/hfidd_internal.h
+++ b/include/linux/hfi/hfidd_internal.h
@@ -39,10 +39,12 @@
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/slab.h>
+#include <linux/jiffies.h>
+#include <linux/device.h>
#include <linux/hfi/hfidd_client.h>
#include <linux/hfi/hfidd_adpt.h>
-
+#include <linux/hfi/hfidd_hcalls.h>
#define HFIDD_DEV_NAME "hfi"
#define HFIDD_CLASS_NAME "hfi"
@@ -65,6 +67,9 @@ struct hfidd_acs {
unsigned int index;
unsigned int acs_cnt;
unsigned int state;
+
+ unsigned int isr;
+
struct device *hfidd_dev;
struct hfidd_dds dds;
};
--
1.7.3.5
^ permalink raw reply related
* [PATCH v4 07/27] HFI: Add nMMU start/stop hypervisor calls
From: dykmanj @ 2011-04-25 21:23 UTC (permalink / raw)
To: netdev
Cc: Jim Dykman, Piyush Chaudhary, Fu-Chung Chang, William S. Cadden,
Wen C. Chen, Scot Sakolish, Jian Xiao, Carol L. Soto,
Sarah J. Sheppard
In-Reply-To: <1303766647-30156-1-git-send-email-dykmanj@linux.vnet.ibm.com>
From: Jim Dykman <dykmanj@linux.vnet.ibm.com>
H_NMMU_START resets/inits state for the nMMU in the hypervisor.
H_NMMU_STOP cleans up hypervisor nMMU state, called on DD unload after HFIs are
stopped.
Signed-off-by: Piyush Chaudhary <piyushc@linux.vnet.ibm.com>
Signed-off-by: Jim Dykman <dykmanj@linux.vnet.ibm.com>
Signed-off-by: Fu-Chung Chang <fcchang@linux.vnet.ibm.com>
Signed-off-by: William S. Cadden <wscadden@linux.vnet.ibm.com>
Signed-off-by: Wen C. Chen <winstonc@linux.vnet.ibm.com>
Signed-off-by: Scot Sakolish <sakolish@linux.vnet.ibm.com>
Signed-off-by: Jian Xiao <jian@linux.vnet.ibm.com>
Signed-off-by: Carol L. Soto <clsoto@linux.vnet.ibm.com>
Signed-off-by: Sarah J. Sheppard <sjsheppa@linux.vnet.ibm.com>
---
drivers/net/hfi/core/hfidd_adpt.c | 36 +++++++++++++++++++++++++++++++++++
drivers/net/hfi/core/hfidd_hcalls.c | 33 ++++++++++++++++++++++++++++++++
drivers/net/hfi/core/hfidd_init.c | 29 +++++++++++++++++++++++++--
drivers/net/hfi/core/hfidd_proto.h | 3 ++
include/linux/hfi/hfidd_hcalls.h | 2 +
5 files changed, 100 insertions(+), 3 deletions(-)
diff --git a/drivers/net/hfi/core/hfidd_adpt.c b/drivers/net/hfi/core/hfidd_adpt.c
index fd4a0cb..487ef0e 100644
--- a/drivers/net/hfi/core/hfidd_adpt.c
+++ b/drivers/net/hfi/core/hfidd_adpt.c
@@ -162,6 +162,42 @@ query1:
return rc;
}
+int hfidd_start_nmmu(struct hfidd_acs *p_acs)
+{
+ long long hvrc;
+ int rc = 0;
+ struct nmmu_info *nmmu_info;
+ caddr_t laddr = NULL;
+ u64 start_time = get_jiffies_64();
+
+ rc = hfidd_get_phyp_page(p_acs, (caddr_t *)&nmmu_info, &laddr,
+ PAGE_SIZE_4K);
+ if (rc) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_start_nmmu: hfidd_get_phyp_page failed\n");
+ return -ENOMEM;
+ }
+
+ while (1) {
+ hvrc = hfi_start_nmmu(p_acs->dds.torr_id,
+ (struct nmmu_info *) laddr);
+ if (hvrc != H_BUSY)
+ break;
+ if (hfidd_age_hcall(start_time))
+ break;
+ }
+
+ if (hvrc != H_SUCCESS) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_start_nmmu: HFI_START_NMMU failed "
+ "hvrc 0x%llx\n", hvrc);
+ rc = -EPERM;
+ }
+
+ hfidd_release_phyp_page((caddr_t)nmmu_info, PAGE_SIZE_4K);
+ return rc;
+}
+
int hfidd_start_interface(struct hfidd_acs *p_acs)
{
long long hvrc = 0;
diff --git a/drivers/net/hfi/core/hfidd_hcalls.c b/drivers/net/hfi/core/hfidd_hcalls.c
index 84467b3..2ca1c8a 100644
--- a/drivers/net/hfi/core/hfidd_hcalls.c
+++ b/drivers/net/hfi/core/hfidd_hcalls.c
@@ -33,6 +33,18 @@
#include <linux/hfi/hfidd_internal.h>
#include "hfidd_proto.h"
+static inline long long h_nmmu_start(int token,
+ u64 torrent_chip_ID,
+ void *output_page_ptr)
+{
+ return plpar_hcall_norets(token, torrent_chip_ID, output_page_ptr);
+}
+
+static inline long long h_nmmu_stop(int token, u64 torrent_chip_ID)
+{
+ return plpar_hcall_norets(token, torrent_chip_ID);
+}
+
static inline long long h_hfi_start_interface(int token,
u64 HFI_chip_ID)
{
@@ -61,6 +73,27 @@ static inline long long h_hfi_query_interface(int token,
return rc;
}
+long long hfi_start_nmmu(u64 chip_id, void *nmmu_info)
+{
+ return h_nmmu_start(H_NMMU_START, chip_id, nmmu_info);
+}
+
+long long hfi_stop_nmmu(u64 chip_id)
+{
+ long long hvrc;
+ u64 start_time = get_jiffies_64();
+
+ while (1) {
+ hvrc = h_nmmu_stop(H_NMMU_STOP,
+ chip_id);
+ if (hvrc != H_BUSY)
+ break;
+ if (hfidd_age_hcall(start_time))
+ break;
+ }
+ return hvrc;
+}
+
long long hfi_hquery_interface(u64 unit_id, u64 subtype,
u64 query_p, u64 *state)
{
diff --git a/drivers/net/hfi/core/hfidd_init.c b/drivers/net/hfi/core/hfidd_init.c
index bbfc477..3dcaa8f 100644
--- a/drivers/net/hfi/core/hfidd_init.c
+++ b/drivers/net/hfi/core/hfidd_init.c
@@ -320,30 +320,43 @@ hfidd_create_devices_error0:
/*
* Disable message passing to each adapter by calling the
- * Stop Interface hcall.
+ * Stop Interface hcall and free phyp NMMU tables for this
+ * lpar by calling STOP NMMU
*/
static void hfidd_stop_adapter(void)
{
int i;
+ long long hvrc;
for (i = 0; i < MAX_HFIS; i++) {
hfidd_stop_interface(hfidd_global.p_acs[i],
hfidd_global.p_acs[i]->dds.hfi_id);
}
+ hvrc = hfi_stop_nmmu(hfidd_global.p_acs[0]->dds.torr_id);
+ if (hvrc != H_SUCCESS)
+ dev_printk(KERN_ERR, hfidd_global.p_acs[0]->hfidd_dev,
+ "%s: hfidd_stop_adapter: HFI_STOP_NMMU failed"
+ " hvrc = 0x%llx\n", HFIDD_DEV_NAME, hvrc);
}
/*
* Query the interface to check the logical state of HFI.
- * Enable message passing to each adapter by calling Start
- * Interface hcall.
+ * Initialize the phyp NMMU tables for this lpar by calling
+ * the START NMMU hcall and enable message passing to each
+ * adapter by calling Start Interface hcall.
*/
static int hfidd_start_adapter(void)
{
+ long long hvrc;
unsigned long long hfi_state;
int i, j;
int rc = 0;
for (i = 0; i < MAX_HFIS; i++) {
+ /* query interface before doing START_NMMU.
+ * If we crashed the LPAR a few minutes ago, we never did the
+ * stop interface and the stop nmmu. Do it now.
+ */
rc = hfidd_query_interface(hfidd_global.p_acs[i], COMP_QUERY,
hfidd_global.p_acs[i]->dds.hfi_id, &hfi_state);
if (hfi_state != NOT_STARTED) {
@@ -374,6 +387,15 @@ static int hfidd_start_adapter(void)
}
+ hfi_stop_nmmu(hfidd_global.p_acs[0]->dds.torr_id);
+ hvrc = hfidd_start_nmmu(hfidd_global.p_acs[0]);
+ if (hvrc != H_SUCCESS) {
+ dev_printk(KERN_ERR, hfidd_global.p_acs[0]->hfidd_dev,
+ "%s: hfidd_start_adapter: HFI_START_NMMU failed"
+ " hvrc = 0x%llx\n", HFIDD_DEV_NAME, hvrc);
+ return -EIO;
+ }
+
for (i = 0; i < MAX_HFIS; i++) {
rc = hfidd_start_interface(hfidd_global.p_acs[i]);
if (rc) {
@@ -402,6 +424,7 @@ hfidd_start_adapter_err:
hfidd_stop_interface(hfidd_global.p_acs[j],
hfidd_global.p_acs[j]->dds.hfi_id);
}
+ hfi_stop_nmmu(hfidd_global.p_acs[0]->dds.torr_id);
return rc;
}
diff --git a/drivers/net/hfi/core/hfidd_proto.h b/drivers/net/hfi/core/hfidd_proto.h
index 6ec9245..320f41f 100644
--- a/drivers/net/hfi/core/hfidd_proto.h
+++ b/drivers/net/hfi/core/hfidd_proto.h
@@ -42,8 +42,11 @@ int hfidd_get_phyp_page(struct hfidd_acs *p_acs, caddr_t *page,
void hfidd_release_phyp_page(caddr_t page, int size);
int hfidd_query_interface(struct hfidd_acs *p_acs, unsigned int subtype,
unsigned int hfi_id, unsigned long long *state);
+int hfidd_start_nmmu(struct hfidd_acs *p_acs);
int hfidd_start_interface(struct hfidd_acs *p_acs);
int hfidd_stop_interface(struct hfidd_acs *p_acs, unsigned int hfi_id);
+long long hfi_start_nmmu(u64 chip_id, void *nmmu_info);
+long long hfi_stop_nmmu(u64 chip_id);
long long hfi_hquery_interface(u64 unit_id, u64 subtype, u64 query_p,
u64 *state);
long long hfi_start_interface(u64 unit_id);
diff --git a/include/linux/hfi/hfidd_hcalls.h b/include/linux/hfi/hfidd_hcalls.h
index 5349e9e..2a374e6 100644
--- a/include/linux/hfi/hfidd_hcalls.h
+++ b/include/linux/hfi/hfidd_hcalls.h
@@ -39,6 +39,8 @@
#define H_HFI_START_INTERFACE 0xF000
#define H_HFI_QUERY_INTERFACE 0xF004
#define H_HFI_STOP_INTERFACE 0xF008
+#define H_NMMU_START 0xF028
+#define H_NMMU_STOP 0xF02C
#define EEH_QUERY 1
#define COMP_QUERY 2
--
1.7.3.5
^ permalink raw reply related
* [PATCH v4 06/27] HFI: Add DD calls to START/STOP INTERFACE HCALLs
From: dykmanj @ 2011-04-25 21:23 UTC (permalink / raw)
To: netdev
Cc: Jim Dykman, Piyush Chaudhary, Fu-Chung Chang, William S. Cadden,
Wen C. Chen, Scot Sakolish, Jian Xiao, Carol L. Soto,
Sarah J. Sheppard
In-Reply-To: <1303766647-30156-1-git-send-email-dykmanj@linux.vnet.ibm.com>
From: Jim Dykman <dykmanj@linux.vnet.ibm.com>
Signed-off-by: Piyush Chaudhary <piyushc@linux.vnet.ibm.com>
Signed-off-by: Jim Dykman <dykmanj@linux.vnet.ibm.com>
Signed-off-by: Fu-Chung Chang <fcchang@linux.vnet.ibm.com>
Signed-off-by: William S. Cadden <wscadden@linux.vnet.ibm.com>
Signed-off-by: Wen C. Chen <winstonc@linux.vnet.ibm.com>
Signed-off-by: Scot Sakolish <sakolish@linux.vnet.ibm.com>
Signed-off-by: Jian Xiao <jian@linux.vnet.ibm.com>
Signed-off-by: Carol L. Soto <clsoto@linux.vnet.ibm.com>
Signed-off-by: Sarah J. Sheppard <sjsheppa@linux.vnet.ibm.com>
---
drivers/net/hfi/core/hfidd_init.c | 97 +++++++++++++++++++++++++++++++++++++
1 files changed, 97 insertions(+), 0 deletions(-)
diff --git a/drivers/net/hfi/core/hfidd_init.c b/drivers/net/hfi/core/hfidd_init.c
index d181d97..bbfc477 100644
--- a/drivers/net/hfi/core/hfidd_init.c
+++ b/drivers/net/hfi/core/hfidd_init.c
@@ -318,6 +318,93 @@ hfidd_create_devices_error0:
return rc;
}
+/*
+ * Disable message passing to each adapter by calling the
+ * Stop Interface hcall.
+ */
+static void hfidd_stop_adapter(void)
+{
+ int i;
+
+ for (i = 0; i < MAX_HFIS; i++) {
+ hfidd_stop_interface(hfidd_global.p_acs[i],
+ hfidd_global.p_acs[i]->dds.hfi_id);
+ }
+}
+
+/*
+ * Query the interface to check the logical state of HFI.
+ * Enable message passing to each adapter by calling Start
+ * Interface hcall.
+ */
+static int hfidd_start_adapter(void)
+{
+ unsigned long long hfi_state;
+ int i, j;
+ int rc = 0;
+
+ for (i = 0; i < MAX_HFIS; i++) {
+ rc = hfidd_query_interface(hfidd_global.p_acs[i], COMP_QUERY,
+ hfidd_global.p_acs[i]->dds.hfi_id, &hfi_state);
+ if (hfi_state != NOT_STARTED) {
+ rc = hfidd_stop_interface(hfidd_global.p_acs[i],
+ hfidd_global.p_acs[i]->dds.hfi_id);
+ if (rc) {
+ dev_printk(KERN_ERR,
+ hfidd_global.p_acs[i]->hfidd_dev,
+ "%s: hfidd_start_adapter:"
+ " hfidd_stop_interface failed rc = "
+ " 0x%x\n", hfidd_global.p_acs[i]->name,
+ rc);
+ }
+
+ rc = hfidd_query_interface(hfidd_global.p_acs[i],
+ COMP_QUERY,
+ hfidd_global.p_acs[i]->dds.hfi_id,
+ &hfi_state);
+ if (hfi_state != NOT_STARTED) {
+ dev_printk(KERN_ERR,
+ hfidd_global.p_acs[i]->hfidd_dev,
+ "%s: hfidd_start_adapter: query"
+ " interface bad state 0x%llx\n",
+ hfidd_global.p_acs[i]->name, hfi_state);
+ return -EIO;
+ }
+ }
+
+ }
+
+ for (i = 0; i < MAX_HFIS; i++) {
+ rc = hfidd_start_interface(hfidd_global.p_acs[i]);
+ if (rc) {
+ dev_printk(KERN_ERR, hfidd_global.p_acs[i]->hfidd_dev,
+ "%s: hfidd_start_adapter: "
+ "hfidd_start_interface failed rc = "
+ "%d\n", hfidd_global.p_acs[i]->name, rc);
+ goto hfidd_start_adapter_err;
+ }
+
+ /* query interface to get src ISR */
+ rc = hfidd_query_interface(hfidd_global.p_acs[i], COMP_QUERY,
+ hfidd_global.p_acs[i]->dds.hfi_id, &hfi_state);
+ if (rc) {
+ dev_printk(KERN_ERR, hfidd_global.p_acs[i]->hfidd_dev,
+ "%s: hfidd_start_adapter: "
+ "hfidd_query_interface failed rc = %d\n",
+ hfidd_global.p_acs[i]->name, rc);
+ goto hfidd_start_adapter_err;
+ }
+ }
+ return 0;
+
+hfidd_start_adapter_err:
+ for (j = 0; j < i; j++) {
+ hfidd_stop_interface(hfidd_global.p_acs[j],
+ hfidd_global.p_acs[j]->dds.hfi_id);
+ }
+ return rc;
+}
+
static int __init hfidd_mod_init(void)
{
int rc = 0;
@@ -338,9 +425,18 @@ static int __init hfidd_mod_init(void)
goto error1;
}
+ rc = hfidd_start_adapter();
+ if (rc < 0) {
+ printk(KERN_ERR "%s: hfidd_mod_init: hfidd_start_adapter failed"
+ " rc = %d\n", HFIDD_DEV_NAME, rc);
+ goto error2;
+ }
+
printk(KERN_INFO "IBM hfi device driver loaded sucessfully\n");
return 0;
+error2:
+ hfidd_destroy_devices();
error1:
hfidd_destroy_class();
return rc;
@@ -348,6 +444,7 @@ error1:
static void __exit hfidd_mod_exit(void)
{
+ hfidd_stop_adapter();
hfidd_destroy_devices();
hfidd_destroy_class();
}
--
1.7.3.5
^ permalink raw reply related
* [PATCH v4 08/27] HFI: DD request framework and first HFI DD request
From: dykmanj @ 2011-04-25 21:23 UTC (permalink / raw)
To: netdev
Cc: Jim Dykman, Piyush Chaudhary, Fu-Chung Chang, William S. Cadden,
Wen C. Chen, Scot Sakolish, Jian Xiao, Carol L. Soto,
Sarah J. Sheppard
In-Reply-To: <1303766647-30156-1-git-send-email-dykmanj@linux.vnet.ibm.com>
From: Jim Dykman <dykmanj@linux.vnet.ibm.com>
We use an ioctl-ish mechanism similar to the one found in the HEA driver.
Some of our requests have very large parameter lists, this method allows
us to get the parms into the DD quickly.
Signed-off-by: Piyush Chaudhary <piyushc@linux.vnet.ibm.com>
Signed-off-by: Jim Dykman <dykmanj@linux.vnet.ibm.com>
Signed-off-by: Fu-Chung Chang <fcchang@linux.vnet.ibm.com>
Signed-off-by: William S. Cadden <wscadden@linux.vnet.ibm.com>
Signed-off-by: Wen C. Chen <winstonc@linux.vnet.ibm.com>
Signed-off-by: Scot Sakolish <sakolish@linux.vnet.ibm.com>
Signed-off-by: Jian Xiao <jian@linux.vnet.ibm.com>
Signed-off-by: Carol L. Soto <clsoto@linux.vnet.ibm.com>
Signed-off-by: Sarah J. Sheppard <sjsheppa@linux.vnet.ibm.com>
---
drivers/net/hfi/core/hfidd_init.c | 94 +++++++++++++++++++++++++++++++++++-
include/linux/hfi/Kbuild | 1 +
include/linux/hfi/hfidd_client.h | 40 +++++++++++++++
include/linux/hfi/hfidd_internal.h | 22 +++++++-
include/linux/hfi/hfidd_requests.h | 38 ++++++++++++++
5 files changed, 191 insertions(+), 4 deletions(-)
create mode 100644 include/linux/hfi/hfidd_requests.h
diff --git a/drivers/net/hfi/core/hfidd_init.c b/drivers/net/hfi/core/hfidd_init.c
index 3dcaa8f..df79ae9 100644
--- a/drivers/net/hfi/core/hfidd_init.c
+++ b/drivers/net/hfi/core/hfidd_init.c
@@ -36,6 +36,7 @@
#include <linux/of.h>
#include <linux/hfi/hfidd_internal.h>
+#include <linux/hfi/hfidd_requests.h>
#include "hfidd_proto.h"
MODULE_VERSION("1.0");
@@ -59,11 +60,102 @@ static ssize_t hfidd_read(struct file *filep, char *buf, size_t count,
return 0;
}
+/* Query firmare level and use abi version to users */
+static int hfidd_query_dd_info(struct hfidd_acs *p_acs,
+ struct hfi_query_dd_info *user_p)
+{
+ struct hfi_query_dd_info req;
+ int rc;
+
+ req.fw_ec_level = p_acs->dds.fw_ec_level;
+ req.abi_version = HFIDD_USER_ABI_VERSION;
+
+ rc = copy_to_user(user_p, &req, sizeof(struct hfi_query_dd_info));
+ if (rc)
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_query_dd_info: copy_to_user failed\n");
+
+ return rc;
+}
+
/* Entry point for user space to do driver requests. */
static ssize_t hfidd_cmd_write(struct file *filep, const char __user *buf,
size_t count, loff_t *pos)
{
- return 0;
+ struct hfidd_acs *p_acs;
+ int ai;
+ int cnt = 0;
+ int rc = 0;
+ struct hfi_req_hdr cmd;
+ int is_userspace;
+
+ ai = iminor(filep->f_path.dentry->d_inode);
+ if (ai >= MAX_HFIS) {
+ printk(KERN_ERR "%s: hfidd_cmd_write: wrong ai = %d\n",
+ HFIDD_DEV_NAME, ai);
+ return -ENODEV;
+ }
+
+ p_acs = hfidd_global.p_acs[ai];
+ if (p_acs == NULL) {
+ printk(KERN_ERR "%s: hfidd_cmd_write: p_acs is NULL\n",
+ HFIDD_DEV_NAME);
+ return -EINVAL;
+ }
+
+ if (count < sizeof(cmd)) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_cmd_write: Invalid count: 0x%lx expected "
+ "count: 0x%lx\n", count, sizeof(cmd));
+ return -EINVAL;
+ }
+
+ is_userspace = 1;
+ if (segment_eq(get_fs(), KERNEL_DS))
+ is_userspace = 0;
+
+ if (copy_from_user(&cmd, buf, sizeof(cmd))) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_cmd_write: copy_from_user failed\n");
+ return -EINVAL;
+ }
+
+ if (cmd.abi_version != HFIDD_USER_ABI_VERSION) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_cmd_write: wrong abi_version %d, "
+ "should be %d for cmd 0x%x\n",
+ cmd.abi_version, HFIDD_USER_ABI_VERSION, cmd.req);
+ return -EINVAL;
+ }
+
+ switch (cmd.req) {
+ case HFIDD_REQ_QUERY_DD_INFO:
+ if (cmd.req_len != sizeof(struct hfi_query_dd_info)) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_cmd_write: hdr.reqlen 0x%x expected "
+ "0x%x for cmd req 0x%x\n",
+ cmd.req_len, (unsigned int)
+ sizeof(struct hfi_query_dd_info), cmd.req);
+ return -EINVAL;
+ }
+ rc = hfidd_query_dd_info(p_acs, (struct hfi_query_dd_info *)
+ cmd.result.use.kptr);
+ break;
+
+ default:
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_cmd_write: invalid cmd = 0x%x\n", cmd.req);
+ return -EINVAL;
+ }
+
+ if (rc == 0)
+ cnt = count;
+ else
+ cnt = rc;
+
+ dev_printk(KERN_INFO, p_acs->hfidd_dev,
+ "hfidd_cmd_write: Exit cmd = 0x%x rc = 0x%x\n", cmd.req, rc);
+ return cnt;
}
static const struct file_operations hfidd_fops = {
diff --git a/include/linux/hfi/Kbuild b/include/linux/hfi/Kbuild
index 3a742ce..6637c65 100644
--- a/include/linux/hfi/Kbuild
+++ b/include/linux/hfi/Kbuild
@@ -1 +1,2 @@
header-y += hfidd_client.h
+header-y += hfidd_requests.h
diff --git a/include/linux/hfi/hfidd_client.h b/include/linux/hfi/hfidd_client.h
index 2714a27..b2ebd01 100644
--- a/include/linux/hfi/hfidd_client.h
+++ b/include/linux/hfi/hfidd_client.h
@@ -33,11 +33,51 @@
#ifndef _HFIDD_CLIENT_H_
#define _HFIDD_CLIENT_H_
+
+#define HFIDD_USER_ABI_VERSION 1
+
+
+/*
+ * New ioctls are not allowed. We will use write() calls to pass
+ * in an ioctl-looking request, with struct hfi_req_hdr giving the
+ * information we used to get from the ioctl() parameter list. The
+ * write() call will copy out the request structure to the buffer pointed
+ * to by result, which is probably the original request.
+ */
+
+struct hfi_64b {
+ union {
+ unsigned long long allu; /* APPLICATION Long long
+ Unsigned 64 bit address
+ container */
+ void *kptr; /* KERNEL Pointer 64 bit
+ container */
+ } use;
+};
+
+/* Request header: first structure in each of the HFI DD requests */
+struct hfi_req_hdr {
+ unsigned int req; /* HFIDD_REQ_* */
+ unsigned int req_len; /* length of req, in bytes */
+ unsigned int abi_version; /* ABI version */
+ struct hfi_64b result; /* user eaddr for output */
+};
+#define HFIDD_REQ_HDR_SIZE sizeof(struct hfi_req_hdr)
+
#define MAX_TORRENTS 1
#define MAX_HFI_PER_TORRENT 2
#define MAX_HFIS (MAX_TORRENTS * MAX_HFI_PER_TORRENT)
#define MAX_WIN_PER_HFI 256
+/*
+ * HFIDD_REQ_QUERY_DD_INFO
+ */
+struct hfi_query_dd_info {
+ struct hfi_req_hdr hdr;
+ unsigned long long fw_ec_level; /* Hardware Version */
+ unsigned int abi_version; /* ABI Version */
+};
+
#define HFI_DYN_WINS_DEFAULT 32
#define PAGE_SIZE_4K 0x1000
diff --git a/include/linux/hfi/hfidd_internal.h b/include/linux/hfi/hfidd_internal.h
index c7c67ca..65b8dc2 100644
--- a/include/linux/hfi/hfidd_internal.h
+++ b/include/linux/hfi/hfidd_internal.h
@@ -36,12 +36,28 @@
#include <linux/fs.h>
#include <linux/kobject.h>
#include <linux/cdev.h>
+#include <linux/compat.h>
+#include <linux/compiler.h>
#include <linux/init.h>
#include <linux/kernel.h>
+#include <linux/mman.h>
+#include <linux/mm.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/poll.h>
#include <linux/slab.h>
-#include <linux/jiffies.h>
-#include <linux/device.h>
-
+#include <linux/delay.h>
+#include <linux/vmalloc.h>
+#include <linux/timer.h>
+#include <linux/spinlock.h>
+#include <linux/sched.h>
+#include <asm/cputable.h>
+#include <linux/io.h>
+#include <asm/machdep.h>
+#include <linux/mmu_context.h>
+#include <asm/pgalloc.h>
+#include <asm/ibmebus.h>
+#include <linux/kthread.h>
#include <linux/hfi/hfidd_client.h>
#include <linux/hfi/hfidd_adpt.h>
#include <linux/hfi/hfidd_hcalls.h>
diff --git a/include/linux/hfi/hfidd_requests.h b/include/linux/hfi/hfidd_requests.h
new file mode 100644
index 0000000..b6e255f
--- /dev/null
+++ b/include/linux/hfi/hfidd_requests.h
@@ -0,0 +1,38 @@
+/*
+ * hfidd_requests.h
+ *
+ * HFI device driver for IBM System p
+ *
+ * Authors:
+ * Fu-Chung Chang <fcchang@linux.vnet.ibm.com>
+ * William S. Cadden <wscadden@linux.vnet.ibm.com>
+ * Wen C. Chen <winstonc@linux.vnet.ibm.com>
+ * Scot Sakolish <sakolish@linux.vnet.ibm.com>
+ * Jian Xiao <jian@linux.vnet.ibm.com>
+ * Carol L. Soto <clsoto@linux.vnet.ibm.com>
+ * Sarah J. Sheppard <sjsheppa@linux.vnet.ibm.com>
+ *
+ * (C) Copyright IBM Corp. 2010
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#ifndef _HFIDD_REQUESTS_H_
+#define _HFIDD_REQUESTS_H_
+
+#define HFIDD_REQ_QUERY_DD_INFO 0x00001004
+
+#endif /* _HFIDD_REQUESTS_H_ */
--
1.7.3.5
^ permalink raw reply related
* [PATCH v4 12/27] HFI: Sanity check send and receive fifo parameters
From: dykmanj @ 2011-04-25 21:23 UTC (permalink / raw)
To: netdev
Cc: Jim Dykman, Piyush Chaudhary, Fu-Chung Chang, William S. Cadden,
Wen C. Chen, Scot Sakolish, Jian Xiao, Carol L. Soto,
Sarah J. Sheppard
In-Reply-To: <1303766647-30156-1-git-send-email-dykmanj@linux.vnet.ibm.com>
From: Jim Dykman <dykmanj@linux.vnet.ibm.com>
Signed-off-by: Piyush Chaudhary <piyushc@linux.vnet.ibm.com>
Signed-off-by: Jim Dykman <dykmanj@linux.vnet.ibm.com>
Signed-off-by: Fu-Chung Chang <fcchang@linux.vnet.ibm.com>
Signed-off-by: William S. Cadden <wscadden@linux.vnet.ibm.com>
Signed-off-by: Wen C. Chen <winstonc@linux.vnet.ibm.com>
Signed-off-by: Scot Sakolish <sakolish@linux.vnet.ibm.com>
Signed-off-by: Jian Xiao <jian@linux.vnet.ibm.com>
Signed-off-by: Carol L. Soto <clsoto@linux.vnet.ibm.com>
Signed-off-by: Sarah J. Sheppard <sjsheppa@linux.vnet.ibm.com>
---
drivers/net/hfi/core/Makefile | 1 +
drivers/net/hfi/core/hfidd_proto.h | 3 +
drivers/net/hfi/core/hfidd_window.c | 177 +++++++++++++++++++++++++++++++++++
drivers/net/hfi/core/hfidd_xlat.c | 131 ++++++++++++++++++++++++++
include/linux/hfi/hfidd_adpt.h | 17 ++++
5 files changed, 329 insertions(+), 0 deletions(-)
create mode 100644 drivers/net/hfi/core/hfidd_xlat.c
diff --git a/drivers/net/hfi/core/Makefile b/drivers/net/hfi/core/Makefile
index 0224a57..8d5558d 100644
--- a/drivers/net/hfi/core/Makefile
+++ b/drivers/net/hfi/core/Makefile
@@ -4,5 +4,6 @@
hfi_core-objs:= hfidd_adpt.o \
hfidd_window.o \
hfidd_init.o \
+ hfidd_xlat.o \
hfidd_hcalls.o
obj-$(CONFIG_HFI) += hfi_core.o
diff --git a/drivers/net/hfi/core/hfidd_proto.h b/drivers/net/hfi/core/hfidd_proto.h
index e7f2901..66ea5da 100644
--- a/drivers/net/hfi/core/hfidd_proto.h
+++ b/drivers/net/hfi/core/hfidd_proto.h
@@ -39,6 +39,9 @@ int hfidd_alloc_windows(struct hfidd_acs *p_acs);
void hfidd_free_windows(struct hfidd_acs *p_acs);
int hfidd_init_adapter(struct hfidd_acs *p_acs, void *uiop);
int hfidd_age_hcall(u64 time_start);
+int hfidd_get_page_size(struct hfidd_acs *p_acs, void *addr,
+ unsigned int is_userspace, unsigned int length,
+ unsigned long long *page_size);
int hfidd_open_window_func(struct hfidd_acs *p_acs, unsigned int is_userspace,
struct hfi_client_info *user_p,
struct hfi_client_info *out_p);
diff --git a/drivers/net/hfi/core/hfidd_window.c b/drivers/net/hfi/core/hfidd_window.c
index cc775e3..5a4f395 100644
--- a/drivers/net/hfi/core/hfidd_window.c
+++ b/drivers/net/hfi/core/hfidd_window.c
@@ -35,6 +35,153 @@
#include "hfidd_proto.h"
#include <linux/hfi/hfidd_requests.h>
+#define FINISH_VECTOR_LENGTH 1
+/* Validate send fifo parameters needed for open window */
+static int hfi_check_sfifo_parm(struct hfidd_acs *p_acs,
+ unsigned int is_userspace,
+ struct hfidd_window *win_p,
+ struct hfi_client_info *client_p)
+{
+ int rc = 0;
+ unsigned long long page_sz;
+ unsigned long long fv_page_sz;
+
+ /* Validate the sfifo size */
+ if ((client_p->sfifo.size < HFI_SFIFO_SIZE_MIN) ||
+ (client_p->sfifo.size > HFI_SFIFO_SIZE_MAX)) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfi_check_sfifo_parm: invalid sfifo "
+ "size = 0x%llx\n",
+ client_p->sfifo.size);
+ return -EINVAL;
+ }
+
+ /*
+ * Validate the address of sfifo is 4k aligned, and finish vector
+ * is cache-line aligned
+ */
+ if ((client_p->sfifo.eaddr.use.allu) & PAGE_MASK_4K) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfi_check_sfifo_parm: not page aligned, "
+ "sfifo_addr = 0x%llx\n",
+ client_p->sfifo.eaddr.use.allu);
+ return -EINVAL;
+ }
+
+ if ((client_p->sfifo_finish_vec.use.allu) & HFI_CACHE_LINE_MASK) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfi_check_sfifo_parm: not cache aligned, "
+ "sfifo_finishvec = 0x%llx\n",
+ client_p->sfifo_finish_vec.use.allu);
+ return -EINVAL;
+ }
+ /*
+ * Validate the send finish vector are within 4K bytes of end of sfifo
+ */
+ if (((client_p->sfifo_finish_vec.use.kptr -
+ (client_p->sfifo.eaddr.use.kptr +
+ client_p->sfifo.size)) >= PAGE_SIZE_4K)) {
+
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfi_check_sfifo_parm: fv too far away, "
+ "sfifo_addr = 0x%llx\n",
+ client_p->sfifo.eaddr.use.allu);
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfi_check_sfifo_parm: fv too far away, "
+ "sfifo_finishvec = 0x%llx\n",
+ client_p->sfifo_finish_vec.use.allu);
+ return -EINVAL;
+ }
+
+ /* Validate page size of sFifo */
+ rc = hfidd_get_page_size(p_acs, client_p->sfifo.eaddr.use.kptr,
+ is_userspace, client_p->sfifo.size, &page_sz);
+ if (rc) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfi_check_sfifo_parm: fail in sfifo page size, "
+ "rc=0x%x\n", rc);
+ return rc;
+ }
+
+ /* Find out the page size of send finish vector */
+ rc = hfidd_get_page_size(p_acs, client_p->sfifo_finish_vec.use.kptr,
+ is_userspace, FINISH_VECTOR_LENGTH, &fv_page_sz);
+ if (rc) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfi_check_sfifo_parm: fail in fv page size, "
+ "rc=0x%x\n", rc);
+ return rc;
+ }
+
+ /* The page size of finish vector must be the same as sfifo */
+ if (page_sz != fv_page_sz) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfi_check_sfifo_parm: diff page sz sf=0x%llx, "
+ "fv0=0x%llx\n", page_sz, fv_page_sz);
+ return -EINVAL;
+ }
+ return 0;
+}
+
+static int hfi_check_rfifo_parm(struct hfidd_acs *p_acs,
+ unsigned int is_userspace,
+ struct hfidd_window *win_p,
+ struct hfi_client_info *client_p)
+{
+ int rc = 0;
+ unsigned long long page_sz;
+
+ /* Validate the rfifo size */
+ if ((client_p->rfifo.size < HFI_RFIFO_SIZE_MIN) ||
+ (client_p->rfifo.size > HFI_RFIFO_SIZE_MAX)) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfi_check_rfifo_parm: invalid rfifo size = 0x%llx\n",
+ client_p->rfifo.size);
+ return -EINVAL;
+ }
+
+ /* Validate the address of rfifo is 4K aligned */
+ if ((client_p->rfifo.eaddr.use.allu) & PAGE_MASK_4K) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfi_check_rfifo_parm: not cache aligned, "
+ "rfifo_addr = 0x%llx\n",
+ client_p->rfifo.eaddr.use.allu);
+ return -EINVAL;
+ }
+
+ /* Validate page size of rFifo */
+ rc = hfidd_get_page_size(p_acs, client_p->rfifo.eaddr.use.kptr,
+ is_userspace, client_p->rfifo.size, &page_sz);
+ if (rc) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfi_check_rfifo_parm: fail in rfifo page size, "
+ "rc=0x%x\n", rc);
+ return rc;
+ }
+ return 0;
+}
+
+/* Validate window parameters to setup the fifos and RDMA function */
+static int hfi_validate_window_request(struct hfidd_acs *p_acs,
+ unsigned int is_userspace, struct hfi_client_info *client_p)
+{
+ int rc = 0;
+ struct hfidd_window *win_p;
+
+ /* Check every input parameters..... */
+ win_p = hfi_window(p_acs, client_p->window);
+
+ /* Check the request of sFifo */
+ rc = hfi_check_sfifo_parm(p_acs, is_userspace, win_p, client_p);
+ if (rc)
+ return rc;
+ /* Check the request of rFifo */
+ rc = hfi_check_rfifo_parm(p_acs, is_userspace, win_p, client_p);
+ if (rc)
+ return rc;
+ return rc;
+}
+
/* Validate the type, state and job id for RESERVED window */
static int hfi_validate_reserve_window_id(struct hfidd_acs *p_acs,
struct hfi_client_info *client_p)
@@ -164,12 +311,29 @@ static inline int hfi_validate_window_id(struct hfidd_acs *p_acs,
return rc;
}
+static inline void hfi_restore_window_parm(struct hfidd_acs *p_acs,
+ struct hfidd_window *win_p)
+{
+ if (win_p->type != HFIDD_RESERVE_WIN) {
+ win_p->type = HFIDD_DYNAMIC_WIN;
+ win_p->job_id = 0;
+ if (win_p->state != WIN_HERROR)
+ win_p->state = WIN_AVAILABLE;
+ } else {
+ if (win_p->state != WIN_HERROR)
+ win_p->state = WIN_RESERVED;
+ }
+ win_p->pid = 0;
+ win_p->is_ip = 0;
+}
+
/* Validate window number and type for open window request */
static int hfi_validate_window_parm(struct hfidd_acs *p_acs,
unsigned int is_userspace,
struct hfi_client_info *client_p)
{
int rc = 0;
+ struct hfidd_window *win_p;
/* Validate the window number */
rc = hfi_validate_window_id(p_acs, client_p, is_userspace);
@@ -179,6 +343,19 @@ static int hfi_validate_window_parm(struct hfidd_acs *p_acs,
"failed, rc = 0x%x\n", rc);
return rc;
}
+
+ rc = hfi_validate_window_request(p_acs, is_userspace, client_p);
+ if (rc) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfi_validate_window_parm: "
+ "hfi_validate_window_request failed, rc = 0x%x\n", rc);
+ win_p = hfi_window(p_acs, client_p->window);
+ spin_lock(&(win_p->win_lock));
+ hfi_restore_window_parm(p_acs, win_p);
+ spin_unlock(&(win_p->win_lock));
+ return rc;
+ }
+
return 0;
}
diff --git a/drivers/net/hfi/core/hfidd_xlat.c b/drivers/net/hfi/core/hfidd_xlat.c
new file mode 100644
index 0000000..23236cc
--- /dev/null
+++ b/drivers/net/hfi/core/hfidd_xlat.c
@@ -0,0 +1,131 @@
+/*
+ * hfidd_xlat.c
+ *
+ * HFI device driver for IBM System p
+ *
+ * Authors:
+ * Fu-Chung Chang <fcchang@linux.vnet.ibm.com>
+ * William S. Cadden <wscadden@linux.vnet.ibm.com>
+ * Wen C. Chen <winstonc@linux.vnet.ibm.com>
+ * Scot Sakolish <sakolish@linux.vnet.ibm.com>
+ * Jian Xiao <jian@linux.vnet.ibm.com>
+ * Carol L. Soto <clsoto@linux.vnet.ibm.com>
+ * Sarah J. Sheppard <sjsheppa@linux.vnet.ibm.com>
+ *
+ * (C) Copyright IBM Corp. 2010
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include <linux/pagemap.h>
+#include <linux/hugetlb.h>
+#include <asm/page.h>
+
+#include <linux/hfi/hfidd_internal.h>
+#include "hfidd_proto.h"
+
+int hfidd_get_page_size(struct hfidd_acs *p_acs, void *addr,
+ unsigned int is_userspace,
+ unsigned int length,
+ unsigned long long *page_size)
+{
+ int rc = 0;
+ int i;
+ int num_pages;
+ struct page **page_list;
+ struct vm_area_struct **vma_list;
+ unsigned long long offset;
+
+ if (!is_userspace) {
+ *page_size = PAGE_SIZE;
+ return 0;
+ }
+
+ offset = (unsigned long long)addr & ~PAGE_MASK;
+ num_pages = PAGE_ALIGN(length + offset) >> PAGE_SHIFT;
+
+ page_list = kzalloc(num_pages * sizeof(struct page *),
+ GFP_KERNEL);
+ if (page_list == NULL) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_get_page_size: kzalloc failed for page_list\n");
+ return -ENOMEM;
+ }
+
+ vma_list = kzalloc(num_pages * sizeof(struct vm_area_struct **),
+ GFP_KERNEL);
+ if (vma_list == NULL) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_get_page_size: kzalloc failed for vma_list\n");
+ rc = -ENOMEM;
+ goto out1;
+ }
+
+ down_read(¤t->mm->mmap_sem);
+ rc = get_user_pages(current, current->mm,
+ (unsigned long long)addr,
+ num_pages, 1, 0, /* yes write, no force */
+ page_list, vma_list);
+ up_read(¤t->mm->mmap_sem);
+
+ if (rc < num_pages) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_get_page_size: get_user_pages failed rc = %d "
+ "and numpages %d\n", rc, num_pages);
+ if (rc < 0)
+ goto out2;
+ num_pages = rc;
+ rc = -ENOMEM;
+ goto out3;
+ }
+
+ rc = 0;
+ *page_size = PAGE_SIZE;
+ for (i = 0; i < num_pages; i++) {
+ /* check for huge pages */
+ if (is_vm_hugetlb_page(vma_list[i])) {
+ /* Find huge page size */
+ *page_size = huge_page_size(hstate_vma(vma_list[i]));
+ break;
+ }
+ }
+
+ /* If memory has huge page size, check if all pages are huge pages */
+ if (*page_size != PAGE_SIZE) {
+ for (i = 0; i < num_pages; i++) {
+ /* if not huge page, set to PAGE_SIZE */
+ if (!is_vm_hugetlb_page(vma_list[i])) {
+ *page_size = PAGE_SIZE;
+ break;
+ }
+ }
+ }
+ if (*page_size == PAGE_SIZE_16G) {
+ dev_printk(KERN_ERR, p_acs->hfidd_dev,
+ "hfidd_get_page_size: Large page size "
+ "0x%llx use 4G\n", *page_size);
+ *page_size = PAGE_SIZE_4G;
+ }
+
+out3:
+ for (i = 0; i < num_pages; i++)
+ page_cache_release(page_list[i]);
+out2:
+ kfree(vma_list);
+out1:
+ kfree(page_list);
+ return rc;
+}
diff --git a/include/linux/hfi/hfidd_adpt.h b/include/linux/hfi/hfidd_adpt.h
index babdb14..a41825f 100644
--- a/include/linux/hfi/hfidd_adpt.h
+++ b/include/linux/hfi/hfidd_adpt.h
@@ -36,6 +36,16 @@
#include <linux/hfi/hfidd_client.h>
+#define HFI_SFIFO_SIZE_MIN 0x10000 /* min = 64K software limit */
+#define HFI_SFIFO_SIZE_MAX 0x800000 /* max = 8M */
+
+#define HFI_RFIFO_SIZE_MIN 0x1000 /* min = 4K */
+#define HFI_RFIFO_SIZE_MAX 0x8000000 /* max = 128M */
+
+#define HFI_CACHE_LINE_SIZE 0x80
+#define HFI_CACHE_LINE_MASK (HFI_CACHE_LINE_SIZE - 1)
+#define HFI_CACHE_LINE_SHIFT 7
+
#define HFI_WNUM_SHIFT 32
#define HFI_CAUNUM_SHIFT 32
#define HFI_SHIFT_OCTANT 3
@@ -57,4 +67,11 @@
#define WIN_PENDING 6
#define WIN_FAIL_CLOSE 7
+#define PAGE_MASK_4K (PAGE_SIZE_4K - 1)
+#define PAGE_MASK_64K (PAGE_SIZE_64K - 1)
+#define PAGE_MASK_1M (PAGE_SIZE_1M - 1)
+#define PAGE_MASK_16M (PAGE_SIZE_16M - 1)
+#define PAGE_MASK_4G (PAGE_SIZE_4G - 1)
+#define PAGE_MASK_16G (PAGE_SIZE_16G - 1)
+
#endif /* _HFIDD_ADPT_H_ */
--
1.7.3.5
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox