* [net-next 09/12] bna: MBOX IRQ Flag Check after Locking
From: Rasesh Mody @ 2011-08-31 1:27 UTC (permalink / raw)
To: davem, netdev; +Cc: adapter_linux_open_src_team, Rasesh Mody, Gurunatha Karaje
In-Reply-To: <1314754068-31978-1-git-send-email-rmody@brocade.com>
Change details:
- Check the BNAD_RF_MBOX_IRQ_DISABLED flag after acquiring the bna_lock,
since checking the flag and executing bna_mbox_handler needs to be atomic.
If not, it opens up window where flag is reset when it was checked, but got
set while spinning on the lock by the other thread which is actually
holding the lock
Signed-off-by: Gurunatha Karaje <gkaraje@brocade.com>
Signed-off-by: Rasesh Mody <rmody@brocade.com>
---
drivers/net/ethernet/brocade/bna/bnad.c | 18 +++++++++++-------
1 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/brocade/bna/bnad.c b/drivers/net/ethernet/brocade/bna/bnad.c
index 0202b98..c6313e8 100644
--- a/drivers/net/ethernet/brocade/bna/bnad.c
+++ b/drivers/net/ethernet/brocade/bna/bnad.c
@@ -586,10 +586,11 @@ bnad_msix_mbox_handler(int irq, void *data)
unsigned long flags;
struct bnad *bnad = (struct bnad *)data;
- if (unlikely(test_bit(BNAD_RF_MBOX_IRQ_DISABLED, &bnad->run_flags)))
- return IRQ_HANDLED;
-
spin_lock_irqsave(&bnad->bna_lock, flags);
+ if (unlikely(test_bit(BNAD_RF_MBOX_IRQ_DISABLED, &bnad->run_flags))) {
+ spin_unlock_irqrestore(&bnad->bna_lock, flags);
+ return IRQ_HANDLED;
+ }
bna_intr_status_get(&bnad->bna, intr_status);
@@ -612,15 +613,18 @@ bnad_isr(int irq, void *data)
struct bnad_rx_ctrl *rx_ctrl;
struct bna_tcb *tcb = NULL;
- if (unlikely(test_bit(BNAD_RF_MBOX_IRQ_DISABLED, &bnad->run_flags)))
+ spin_lock_irqsave(&bnad->bna_lock, flags);
+ if (unlikely(test_bit(BNAD_RF_MBOX_IRQ_DISABLED, &bnad->run_flags))) {
+ spin_unlock_irqrestore(&bnad->bna_lock, flags);
return IRQ_NONE;
+ }
bna_intr_status_get(&bnad->bna, intr_status);
- if (unlikely(!intr_status))
+ if (unlikely(!intr_status)) {
+ spin_unlock_irqrestore(&bnad->bna_lock, flags);
return IRQ_NONE;
-
- spin_lock_irqsave(&bnad->bna_lock, flags);
+ }
if (BNA_IS_MBOX_ERR_INTR(&bnad->bna, intr_status))
bna_mbox_handler(&bnad->bna, intr_status);
--
1.7.1
^ permalink raw reply related
* [net-next 08/12] bna: Async Mode Tx Rx Init Fix
From: Rasesh Mody @ 2011-08-31 1:27 UTC (permalink / raw)
To: davem, netdev; +Cc: adapter_linux_open_src_team, Rasesh Mody, Gurunatha Karaje
In-Reply-To: <1314754068-31978-1-git-send-email-rmody@brocade.com>
Change details:
- Async mode of Tx/Rx queue initialization in BNAD from a task queue context
runs into non-unique taskq allocation issues. Get rid of Tx/Rx
initialization from task q context
- In the attach function, wait for IOC enable, then do Tx/Rx queue
initialization. Default BNA attributes are used when IOC enable from attach
fails and values are set to:
1 TxQ, 1 RxQ, 1 Unicast MAC, 1 RIT entry
Signed-off-by: Gurunatha Karaje <gkaraje@brocade.com>
Signed-off-by: Rasesh Mody <rmody@brocade.com>
---
drivers/net/ethernet/brocade/bna/bna_enet.c | 29 ++++++++++++++++++-----
drivers/net/ethernet/brocade/bna/bna_hw_defs.h | 4 +++
drivers/net/ethernet/brocade/bna/bna_types.h | 1 +
3 files changed, 27 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/brocade/bna/bna_enet.c b/drivers/net/ethernet/brocade/bna/bna_enet.c
index 68a275d..26f5c5a 100644
--- a/drivers/net/ethernet/brocade/bna/bna_enet.c
+++ b/drivers/net/ethernet/brocade/bna/bna_enet.c
@@ -167,13 +167,14 @@ bna_bfi_attr_get_rsp(struct bna_ioceth *ioceth,
* Store only if not set earlier, since BNAD can override the HW
* attributes
*/
- if (!ioceth->attr.num_txq)
+ if (!ioceth->attr.fw_query_complete) {
ioceth->attr.num_txq = ntohl(rsp->max_cfg);
- if (!ioceth->attr.num_rxp)
ioceth->attr.num_rxp = ntohl(rsp->max_cfg);
- ioceth->attr.num_ucmac = ntohl(rsp->max_ucmac);
- ioceth->attr.num_mcmac = BFI_ENET_MAX_MCAM;
- ioceth->attr.max_rit_size = ntohl(rsp->rit_size);
+ ioceth->attr.num_ucmac = ntohl(rsp->max_ucmac);
+ ioceth->attr.num_mcmac = BFI_ENET_MAX_MCAM;
+ ioceth->attr.max_rit_size = ntohl(rsp->rit_size);
+ ioceth->attr.fw_query_complete = true;
+ }
bfa_fsm_send_event(ioceth, IOCETH_E_ENET_ATTR_RESP);
}
@@ -1693,6 +1694,16 @@ static struct bfa_ioc_cbfn bna_ioceth_cbfn = {
bna_cb_ioceth_reset
};
+static void bna_attr_init(struct bna_ioceth *ioceth)
+{
+ ioceth->attr.num_txq = BFI_ENET_DEF_TXQ;
+ ioceth->attr.num_rxp = BFI_ENET_DEF_RXP;
+ ioceth->attr.num_ucmac = BFI_ENET_DEF_UCAM;
+ ioceth->attr.num_mcmac = BFI_ENET_MAX_MCAM;
+ ioceth->attr.max_rit_size = BFI_ENET_DEF_RITSZ;
+ ioceth->attr.fw_query_complete = false;
+}
+
static void
bna_ioceth_init(struct bna_ioceth *ioceth, struct bna *bna,
struct bna_res_info *res_info)
@@ -1738,6 +1749,8 @@ bna_ioceth_init(struct bna_ioceth *ioceth, struct bna *bna,
ioceth->stop_cbfn = NULL;
ioceth->stop_cbarg = NULL;
+ bna_attr_init(ioceth);
+
bfa_fsm_set_state(ioceth, bna_ioceth_sm_stopped);
}
@@ -2036,7 +2049,8 @@ bna_uninit(struct bna *bna)
int
bna_num_txq_set(struct bna *bna, int num_txq)
{
- if (num_txq > 0 && (num_txq <= bna->ioceth.attr.num_txq)) {
+ if (bna->ioceth.attr.fw_query_complete &&
+ (num_txq <= bna->ioceth.attr.num_txq)) {
bna->ioceth.attr.num_txq = num_txq;
return BNA_CB_SUCCESS;
}
@@ -2047,7 +2061,8 @@ bna_num_txq_set(struct bna *bna, int num_txq)
int
bna_num_rxp_set(struct bna *bna, int num_rxp)
{
- if (num_rxp > 0 && (num_rxp <= bna->ioceth.attr.num_rxp)) {
+ if (bna->ioceth.attr.fw_query_complete &&
+ (num_rxp <= bna->ioceth.attr.num_rxp)) {
bna->ioceth.attr.num_rxp = num_rxp;
return BNA_CB_SUCCESS;
}
diff --git a/drivers/net/ethernet/brocade/bna/bna_hw_defs.h b/drivers/net/ethernet/brocade/bna/bna_hw_defs.h
index 7ecdca5..dde8a46 100644
--- a/drivers/net/ethernet/brocade/bna/bna_hw_defs.h
+++ b/drivers/net/ethernet/brocade/bna/bna_hw_defs.h
@@ -30,6 +30,10 @@
* SW imposed limits
*
*/
+#define BFI_ENET_DEF_TXQ 1
+#define BFI_ENET_DEF_RXP 1
+#define BFI_ENET_DEF_UCAM 1
+#define BFI_ENET_DEF_RITSZ 1
#define BFI_ENET_MAX_MCAM 256
diff --git a/drivers/net/ethernet/brocade/bna/bna_types.h b/drivers/net/ethernet/brocade/bna/bna_types.h
index 59417b1..242d799 100644
--- a/drivers/net/ethernet/brocade/bna/bna_types.h
+++ b/drivers/net/ethernet/brocade/bna/bna_types.h
@@ -323,6 +323,7 @@ struct bna_qpt {
};
struct bna_attr {
+ bool fw_query_complete;
int num_txq;
int num_rxp;
int num_ucmac;
--
1.7.1
^ permalink raw reply related
* [net-next 10/12] bna: TX Queue Depth Fix
From: Rasesh Mody @ 2011-08-31 1:27 UTC (permalink / raw)
To: davem, netdev; +Cc: adapter_linux_open_src_team, Rasesh Mody, Gurunatha Karaje
In-Reply-To: <1314754068-31978-1-git-send-email-rmody@brocade.com>
sk_buff unmap_array grows greater than 65536 (x2) with Tx ring of 65536.
Reducing TXQ depth and safe(max) acking of Tx events to 32768 (same as Rx).
Add defines for TX and RX queue depths.
Signed-off-by: Gurunatha Karaje <gkaraje@brocade.com>
Signed-off-by: Rasesh Mody <rmody@brocade.com>
---
drivers/net/ethernet/brocade/bna/bnad.h | 4 ++++
drivers/net/ethernet/brocade/bna/bnad_ethtool.c | 8 ++++----
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/brocade/bna/bnad.h b/drivers/net/ethernet/brocade/bna/bnad.h
index 0c9d736..6c42c14 100644
--- a/drivers/net/ethernet/brocade/bna/bnad.h
+++ b/drivers/net/ethernet/brocade/bna/bnad.h
@@ -86,6 +86,10 @@ struct bnad_rx_ctrl {
#define BNAD_MAX_Q_DEPTH 0x10000
#define BNAD_MIN_Q_DEPTH 0x200
+#define BNAD_MAX_RXQ_DEPTH (BNAD_MAX_Q_DEPTH / bnad_rxqs_per_cq)
+/* keeping MAX TX and RX Q depth equal */
+#define BNAD_MAX_TXQ_DEPTH BNAD_MAX_RXQ_DEPTH
+
#define BNAD_JUMBO_MTU 9000
#define BNAD_NETIF_WAKE_THRESHOLD 8
diff --git a/drivers/net/ethernet/brocade/bna/bnad_ethtool.c b/drivers/net/ethernet/brocade/bna/bnad_ethtool.c
index 96ff700..4842224 100644
--- a/drivers/net/ethernet/brocade/bna/bnad_ethtool.c
+++ b/drivers/net/ethernet/brocade/bna/bnad_ethtool.c
@@ -418,10 +418,10 @@ bnad_get_ringparam(struct net_device *netdev,
{
struct bnad *bnad = netdev_priv(netdev);
- ringparam->rx_max_pending = BNAD_MAX_Q_DEPTH / bnad_rxqs_per_cq;
+ ringparam->rx_max_pending = BNAD_MAX_RXQ_DEPTH;
ringparam->rx_mini_max_pending = 0;
ringparam->rx_jumbo_max_pending = 0;
- ringparam->tx_max_pending = BNAD_MAX_Q_DEPTH;
+ ringparam->tx_max_pending = BNAD_MAX_TXQ_DEPTH;
ringparam->rx_pending = bnad->rxq_depth;
ringparam->rx_mini_max_pending = 0;
@@ -445,13 +445,13 @@ bnad_set_ringparam(struct net_device *netdev,
}
if (ringparam->rx_pending < BNAD_MIN_Q_DEPTH ||
- ringparam->rx_pending > BNAD_MAX_Q_DEPTH / bnad_rxqs_per_cq ||
+ ringparam->rx_pending > BNAD_MAX_RXQ_DEPTH ||
!BNA_POWER_OF_2(ringparam->rx_pending)) {
mutex_unlock(&bnad->conf_mutex);
return -EINVAL;
}
if (ringparam->tx_pending < BNAD_MIN_Q_DEPTH ||
- ringparam->tx_pending > BNAD_MAX_Q_DEPTH ||
+ ringparam->tx_pending > BNAD_MAX_TXQ_DEPTH ||
!BNA_POWER_OF_2(ringparam->tx_pending)) {
mutex_unlock(&bnad->conf_mutex);
return -EINVAL;
--
1.7.1
^ permalink raw reply related
* [net-next 11/12] bna: SKB PCI UNMAP Fix
From: Rasesh Mody @ 2011-08-31 1:27 UTC (permalink / raw)
To: davem, netdev; +Cc: adapter_linux_open_src_team, Rasesh Mody, Gurunatha Karaje
In-Reply-To: <1314754068-31978-1-git-send-email-rmody@brocade.com>
Change details:
- Found a leak in sk_buff unmapping of PCI dma addresses where boundary
conditions are not properly handled in freeing all Tx buffers. Freeing
of all Tx buffers is done considering sk_buffs data and fragments can
be mapped at the boundary.
Signed-off-by: Gurunatha Karaje <gkaraje@brocade.com>
Signed-off-by: Rasesh Mody <rmody@brocade.com>
---
drivers/net/ethernet/brocade/bna/bnad.c | 39 ++++++++-----------------------
1 files changed, 10 insertions(+), 29 deletions(-)
diff --git a/drivers/net/ethernet/brocade/bna/bnad.c b/drivers/net/ethernet/brocade/bna/bnad.c
index c6313e8..b7f96ab 100644
--- a/drivers/net/ethernet/brocade/bna/bnad.c
+++ b/drivers/net/ethernet/brocade/bna/bnad.c
@@ -137,39 +137,20 @@ bnad_free_all_txbufs(struct bnad *bnad,
struct bnad_unmap_q *unmap_q = tcb->unmap_q;
struct bnad_skb_unmap *unmap_array;
struct sk_buff *skb = NULL;
- int i;
+ int q;
unmap_array = unmap_q->unmap_array;
- unmap_cons = 0;
- while (unmap_cons < unmap_q->q_depth) {
- skb = unmap_array[unmap_cons].skb;
- if (!skb) {
- unmap_cons++;
+ for (q = 0; q < unmap_q->q_depth; q++) {
+ skb = unmap_array[q].skb;
+ if (!skb)
continue;
- }
- unmap_array[unmap_cons].skb = NULL;
-
- dma_unmap_single(&bnad->pcidev->dev,
- dma_unmap_addr(&unmap_array[unmap_cons],
- dma_addr), skb_headlen(skb),
- DMA_TO_DEVICE);
- dma_unmap_addr_set(&unmap_array[unmap_cons], dma_addr, 0);
- if (++unmap_cons >= unmap_q->q_depth)
- break;
+ unmap_cons = q;
+ unmap_cons = bnad_pci_unmap_skb(&bnad->pcidev->dev, unmap_array,
+ unmap_cons, unmap_q->q_depth, skb,
+ skb_shinfo(skb)->nr_frags);
- for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
- dma_unmap_page(&bnad->pcidev->dev,
- dma_unmap_addr(&unmap_array[unmap_cons],
- dma_addr),
- skb_shinfo(skb)->frags[i].size,
- DMA_TO_DEVICE);
- dma_unmap_addr_set(&unmap_array[unmap_cons], dma_addr,
- 0);
- if (++unmap_cons >= unmap_q->q_depth)
- break;
- }
dev_kfree_skb_any(skb);
}
}
--
1.7.1
^ permalink raw reply related
* [net-next 12/12] bna: Driver Version changed to 3.0.2.1
From: Rasesh Mody @ 2011-08-31 1:27 UTC (permalink / raw)
To: davem, netdev; +Cc: adapter_linux_open_src_team, Rasesh Mody, Gurunatha Karaje
In-Reply-To: <1314754068-31978-1-git-send-email-rmody@brocade.com>
Signed-off-by: Gurunatha Karaje <gkaraje@brocade.com>
Signed-off-by: Rasesh Mody <rmody@brocade.com>
---
drivers/net/ethernet/brocade/bna/bnad.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/net/ethernet/brocade/bna/bnad.h b/drivers/net/ethernet/brocade/bna/bnad.h
index 6c42c14..1c9328d 100644
--- a/drivers/net/ethernet/brocade/bna/bnad.h
+++ b/drivers/net/ethernet/brocade/bna/bnad.h
@@ -71,7 +71,7 @@ struct bnad_rx_ctrl {
#define BNAD_NAME "bna"
#define BNAD_NAME_LEN 64
-#define BNAD_VERSION "3.0.2.0"
+#define BNAD_VERSION "3.0.2.1"
#define BNAD_MAILBOX_MSIX_INDEX 0
#define BNAD_MAILBOX_MSIX_VECTORS 1
--
1.7.1
^ permalink raw reply related
* Re: [net-next 10/12] bna: TX Queue Depth Fix
From: Eric Dumazet @ 2011-08-31 4:24 UTC (permalink / raw)
To: Rasesh Mody; +Cc: davem, netdev, adapter_linux_open_src_team, Gurunatha Karaje
In-Reply-To: <1314754068-31978-11-git-send-email-rmody@brocade.com>
Le mardi 30 août 2011 à 18:27 -0700, Rasesh Mody a écrit :
> sk_buff unmap_array grows greater than 65536 (x2) with Tx ring of 65536.
> Reducing TXQ depth and safe(max) acking of Tx events to 32768 (same as Rx).
> Add defines for TX and RX queue depths.
>
> Signed-off-by: Gurunatha Karaje <gkaraje@brocade.com>
> Signed-off-by: Rasesh Mody <rmody@brocade.com>
> ---
> drivers/net/ethernet/brocade/bna/bnad.h | 4 ++++
> drivers/net/ethernet/brocade/bna/bnad_ethtool.c | 8 ++++----
> 2 files changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/ethernet/brocade/bna/bnad.h b/drivers/net/ethernet/brocade/bna/bnad.h
> index 0c9d736..6c42c14 100644
> --- a/drivers/net/ethernet/brocade/bna/bnad.h
> +++ b/drivers/net/ethernet/brocade/bna/bnad.h
> @@ -86,6 +86,10 @@ struct bnad_rx_ctrl {
> #define BNAD_MAX_Q_DEPTH 0x10000
> #define BNAD_MIN_Q_DEPTH 0x200
>
> +#define BNAD_MAX_RXQ_DEPTH (BNAD_MAX_Q_DEPTH / bnad_rxqs_per_cq)
> +/* keeping MAX TX and RX Q depth equal */
> +#define BNAD_MAX_TXQ_DEPTH BNAD_MAX_RXQ_DEPTH
> +
> #define BNAD_JUMBO_MTU 9000
>
> #define BNAD_NETIF_WAKE_THRESHOLD 8
> diff --git a/drivers/net/ethernet/brocade/bna/bnad_ethtool.c b/drivers/net/ethernet/brocade/bna/bnad_ethtool.c
> index 96ff700..4842224 100644
> --- a/drivers/net/ethernet/brocade/bna/bnad_ethtool.c
> +++ b/drivers/net/ethernet/brocade/bna/bnad_ethtool.c
> @@ -418,10 +418,10 @@ bnad_get_ringparam(struct net_device *netdev,
> {
> struct bnad *bnad = netdev_priv(netdev);
>
> - ringparam->rx_max_pending = BNAD_MAX_Q_DEPTH / bnad_rxqs_per_cq;
> + ringparam->rx_max_pending = BNAD_MAX_RXQ_DEPTH;
> ringparam->rx_mini_max_pending = 0;
> ringparam->rx_jumbo_max_pending = 0;
> - ringparam->tx_max_pending = BNAD_MAX_Q_DEPTH;
> + ringparam->tx_max_pending = BNAD_MAX_TXQ_DEPTH;
>
> ringparam->rx_pending = bnad->rxq_depth;
> ringparam->rx_mini_max_pending = 0;
> @@ -445,13 +445,13 @@ bnad_set_ringparam(struct net_device *netdev,
> }
>
> if (ringparam->rx_pending < BNAD_MIN_Q_DEPTH ||
> - ringparam->rx_pending > BNAD_MAX_Q_DEPTH / bnad_rxqs_per_cq ||
> + ringparam->rx_pending > BNAD_MAX_RXQ_DEPTH ||
> !BNA_POWER_OF_2(ringparam->rx_pending)) {
> mutex_unlock(&bnad->conf_mutex);
> return -EINVAL;
> }
> if (ringparam->tx_pending < BNAD_MIN_Q_DEPTH ||
> - ringparam->tx_pending > BNAD_MAX_Q_DEPTH ||
> + ringparam->tx_pending > BNAD_MAX_TXQ_DEPTH ||
> !BNA_POWER_OF_2(ringparam->tx_pending)) {
> mutex_unlock(&bnad->conf_mutex);
> return -EINVAL;
BNAD_MAX_Q_DEPTH is now defined but not used.
BTW, 32768 slots in a RX queue is insane.
^ permalink raw reply
* Re: [net-next 10/12] bna: TX Queue Depth Fix
From: Dave Taht @ 2011-08-31 4:34 UTC (permalink / raw)
To: Eric Dumazet
Cc: Rasesh Mody, davem, netdev, adapter_linux_open_src_team,
Gurunatha Karaje
In-Reply-To: <1314764670.2556.23.camel@edumazet-laptop>
On Tue, Aug 30, 2011 at 9:24 PM, Eric Dumazet <eric.dumazet@gmail.com> wrote:
> Le mardi 30 août 2011 à 18:27 -0700, Rasesh Mody a écrit :
>> sk_buff unmap_array grows greater than 65536 (x2) with Tx ring of 65536.
>> Reducing TXQ depth and safe(max) acking of Tx events to 32768 (same as Rx).
>> Add defines for TX and RX queue depths.
I was happy at the 'reducing txq depth' portion of the email, then I
saw the value it was reduced to.
thx for commenting thusly...
> BNAD_MAX_Q_DEPTH is now defined but not used.
>
> BTW, 32768 slots in a RX queue is insane.
As that is many lunar distances worth of buffering... Are they
expecting transmissions from mars?
--
Dave Täht
SKYPE: davetaht
US Tel: 1-239-829-5608
http://the-edge.blogspot.com
^ permalink raw reply
* Re: [net-next 10/12] bna: TX Queue Depth Fix
From: Eric Dumazet @ 2011-08-31 4:46 UTC (permalink / raw)
To: Dave Taht
Cc: Rasesh Mody, davem, netdev, adapter_linux_open_src_team,
Gurunatha Karaje
In-Reply-To: <CAA93jw7OrqruzEu4EzEubqFdKpLrkPN9ksh5SSqU5pVcSCjgcw@mail.gmail.com>
Le mardi 30 août 2011 à 21:34 -0700, Dave Taht a écrit :
> On Tue, Aug 30, 2011 at 9:24 PM, Eric Dumazet <eric.dumazet@gmail.com> wrote:
> > BNAD_MAX_Q_DEPTH is now defined but not used.
> >
> > BTW, 32768 slots in a RX queue is insane.
>
> As that is many lunar distances worth of buffering... Are they
> expecting transmissions from mars?
>
At 10GB rate, this can be filled in ~2msec with small frames.
Apparently some people business depend on not losing frames.
But they should be warned of extra memory needs, and latency increases
(because of a larger working set)
^ permalink raw reply
* [PATCH RFT v2] bnx2: don't request firmware when there's no userspace.
From: Francois Romieu @ 2011-08-31 4:48 UTC (permalink / raw)
To: Michael Chan; +Cc: davem, netdev
The firmware is cached during the first successful call to open() and
released once the network device is unregistered. The driver uses the
cached firmware between open() and unregister_netdev().
It's similar to 953a12cc2889d1be92e80a2d0bab5ffef4942300 but the
firmware is mandatory.
Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
Cc: Michael Chan <mchan@broadcom.com>
---
Since v1: conditional release in bnx2_release_firmware.
drivers/net/bnx2.c | 62 ++++++++++++++++++++++++++++++++-------------------
1 files changed, 39 insertions(+), 23 deletions(-)
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index 4b2b570..5764333 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -3649,8 +3649,17 @@ check_mips_fw_entry(const struct firmware *fw,
return 0;
}
+static void bnx2_release_firmware(struct bnx2 *bp)
+{
+ if (bp->rv2p_firmware) {
+ release_firmware(bp->mips_firmware);
+ release_firmware(bp->rv2p_firmware);
+ bp->rv2p_firmware = NULL;
+ }
+}
+
static int __devinit
-bnx2_request_firmware(struct bnx2 *bp)
+bnx2_request_uncached_firmware(struct bnx2 *bp)
{
const char *mips_fw_file, *rv2p_fw_file;
const struct bnx2_mips_fw_file *mips_fw;
@@ -3672,13 +3681,13 @@ bnx2_request_firmware(struct bnx2 *bp)
rc = request_firmware(&bp->mips_firmware, mips_fw_file, &bp->pdev->dev);
if (rc) {
pr_err("Can't load firmware file \"%s\"\n", mips_fw_file);
- return rc;
+ goto out;
}
rc = request_firmware(&bp->rv2p_firmware, rv2p_fw_file, &bp->pdev->dev);
if (rc) {
pr_err("Can't load firmware file \"%s\"\n", rv2p_fw_file);
- return rc;
+ goto err_release_mips_firmware;
}
mips_fw = (const struct bnx2_mips_fw_file *) bp->mips_firmware->data;
rv2p_fw = (const struct bnx2_rv2p_fw_file *) bp->rv2p_firmware->data;
@@ -3689,16 +3698,30 @@ bnx2_request_firmware(struct bnx2 *bp)
check_mips_fw_entry(bp->mips_firmware, &mips_fw->tpat) ||
check_mips_fw_entry(bp->mips_firmware, &mips_fw->txp)) {
pr_err("Firmware file \"%s\" is invalid\n", mips_fw_file);
- return -EINVAL;
+ rc = -EINVAL;
+ goto err_release_firmware;
}
if (bp->rv2p_firmware->size < sizeof(*rv2p_fw) ||
check_fw_section(bp->rv2p_firmware, &rv2p_fw->proc1.rv2p, 8, true) ||
check_fw_section(bp->rv2p_firmware, &rv2p_fw->proc2.rv2p, 8, true)) {
pr_err("Firmware file \"%s\" is invalid\n", rv2p_fw_file);
- return -EINVAL;
+ rc = -EINVAL;
+ goto err_release_firmware;
}
+out:
+ return rc;
- return 0;
+err_release_firmware:
+ release_firmware(bp->rv2p_firmware);
+ bp->rv2p_firmware = NULL;
+err_release_mips_firmware:
+ release_firmware(bp->mips_firmware);
+ goto out;
+}
+
+static int bnx2_request_firmware(struct bnx2 *bp)
+{
+ return bp->rv2p_firmware ? 0 : bnx2_request_uncached_firmware(bp);
}
static u32
@@ -6266,6 +6289,10 @@ bnx2_open(struct net_device *dev)
struct bnx2 *bp = netdev_priv(dev);
int rc;
+ rc = bnx2_request_firmware(bp);
+ if (rc < 0)
+ goto out;
+
netif_carrier_off(dev);
bnx2_set_power_state(bp, PCI_D0);
@@ -6326,8 +6353,8 @@ bnx2_open(struct net_device *dev)
netdev_info(dev, "using MSIX\n");
netif_tx_start_all_queues(dev);
-
- return 0;
+out:
+ return rc;
open_err:
bnx2_napi_disable(bp);
@@ -6335,7 +6362,8 @@ open_err:
bnx2_free_irq(bp);
bnx2_free_mem(bp);
bnx2_del_napi(bp);
- return rc;
+ bnx2_release_firmware(bp);
+ goto out;
}
static void
@@ -8353,10 +8381,6 @@ bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
pci_set_drvdata(pdev, dev);
- rc = bnx2_request_firmware(bp);
- if (rc)
- goto error;
-
memcpy(dev->dev_addr, bp->mac_addr, 6);
memcpy(dev->perm_addr, bp->mac_addr, 6);
@@ -8387,11 +8411,6 @@ bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
return 0;
error:
- if (bp->mips_firmware)
- release_firmware(bp->mips_firmware);
- if (bp->rv2p_firmware)
- release_firmware(bp->rv2p_firmware);
-
if (bp->regview)
iounmap(bp->regview);
pci_release_regions(pdev);
@@ -8412,11 +8431,6 @@ bnx2_remove_one(struct pci_dev *pdev)
del_timer_sync(&bp->timer);
cancel_work_sync(&bp->reset_task);
- if (bp->mips_firmware)
- release_firmware(bp->mips_firmware);
- if (bp->rv2p_firmware)
- release_firmware(bp->rv2p_firmware);
-
if (bp->regview)
iounmap(bp->regview);
@@ -8427,6 +8441,8 @@ bnx2_remove_one(struct pci_dev *pdev)
bp->flags &= ~BNX2_FLAG_AER_ENABLED;
}
+ bnx2_release_firmware(bp);
+
free_netdev(dev);
pci_release_regions(pdev);
--
1.7.4.4
^ permalink raw reply related
* [PATCH RFT v3] bnx2: don't request firmware when there's no userspace.
From: Francois Romieu @ 2011-08-31 4:59 UTC (permalink / raw)
To: Michael Chan; +Cc: davem, netdev
The firmware is cached during the first successful call to open() and
released once the network device is unregistered. The driver uses the
cached firmware between open() and unregister_netdev().
It's similar to 953a12cc2889d1be92e80a2d0bab5ffef4942300 but the
firmware is mandatory.
Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
Reviewed-by: Michael Chan <mchan@broadcom.com>
---
Since v2: remove erroneous __devinit.
Since v1: conditional release in bnx2_release_firmware.
drivers/net/bnx2.c | 64 ++++++++++++++++++++++++++++++++-------------------
1 files changed, 40 insertions(+), 24 deletions(-)
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index 4b2b570..87a21c1 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -3649,8 +3649,17 @@ check_mips_fw_entry(const struct firmware *fw,
return 0;
}
-static int __devinit
-bnx2_request_firmware(struct bnx2 *bp)
+static void bnx2_release_firmware(struct bnx2 *bp)
+{
+ if (bp->rv2p_firmware) {
+ release_firmware(bp->mips_firmware);
+ release_firmware(bp->rv2p_firmware);
+ bp->rv2p_firmware = NULL;
+ }
+}
+
+static int
+bnx2_request_uncached_firmware(struct bnx2 *bp)
{
const char *mips_fw_file, *rv2p_fw_file;
const struct bnx2_mips_fw_file *mips_fw;
@@ -3672,13 +3681,13 @@ bnx2_request_firmware(struct bnx2 *bp)
rc = request_firmware(&bp->mips_firmware, mips_fw_file, &bp->pdev->dev);
if (rc) {
pr_err("Can't load firmware file \"%s\"\n", mips_fw_file);
- return rc;
+ goto out;
}
rc = request_firmware(&bp->rv2p_firmware, rv2p_fw_file, &bp->pdev->dev);
if (rc) {
pr_err("Can't load firmware file \"%s\"\n", rv2p_fw_file);
- return rc;
+ goto err_release_mips_firmware;
}
mips_fw = (const struct bnx2_mips_fw_file *) bp->mips_firmware->data;
rv2p_fw = (const struct bnx2_rv2p_fw_file *) bp->rv2p_firmware->data;
@@ -3689,16 +3698,30 @@ bnx2_request_firmware(struct bnx2 *bp)
check_mips_fw_entry(bp->mips_firmware, &mips_fw->tpat) ||
check_mips_fw_entry(bp->mips_firmware, &mips_fw->txp)) {
pr_err("Firmware file \"%s\" is invalid\n", mips_fw_file);
- return -EINVAL;
+ rc = -EINVAL;
+ goto err_release_firmware;
}
if (bp->rv2p_firmware->size < sizeof(*rv2p_fw) ||
check_fw_section(bp->rv2p_firmware, &rv2p_fw->proc1.rv2p, 8, true) ||
check_fw_section(bp->rv2p_firmware, &rv2p_fw->proc2.rv2p, 8, true)) {
pr_err("Firmware file \"%s\" is invalid\n", rv2p_fw_file);
- return -EINVAL;
+ rc = -EINVAL;
+ goto err_release_firmware;
}
+out:
+ return rc;
- return 0;
+err_release_firmware:
+ release_firmware(bp->rv2p_firmware);
+ bp->rv2p_firmware = NULL;
+err_release_mips_firmware:
+ release_firmware(bp->mips_firmware);
+ goto out;
+}
+
+static int bnx2_request_firmware(struct bnx2 *bp)
+{
+ return bp->rv2p_firmware ? 0 : bnx2_request_uncached_firmware(bp);
}
static u32
@@ -6266,6 +6289,10 @@ bnx2_open(struct net_device *dev)
struct bnx2 *bp = netdev_priv(dev);
int rc;
+ rc = bnx2_request_firmware(bp);
+ if (rc < 0)
+ goto out;
+
netif_carrier_off(dev);
bnx2_set_power_state(bp, PCI_D0);
@@ -6326,8 +6353,8 @@ bnx2_open(struct net_device *dev)
netdev_info(dev, "using MSIX\n");
netif_tx_start_all_queues(dev);
-
- return 0;
+out:
+ return rc;
open_err:
bnx2_napi_disable(bp);
@@ -6335,7 +6362,8 @@ open_err:
bnx2_free_irq(bp);
bnx2_free_mem(bp);
bnx2_del_napi(bp);
- return rc;
+ bnx2_release_firmware(bp);
+ goto out;
}
static void
@@ -8353,10 +8381,6 @@ bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
pci_set_drvdata(pdev, dev);
- rc = bnx2_request_firmware(bp);
- if (rc)
- goto error;
-
memcpy(dev->dev_addr, bp->mac_addr, 6);
memcpy(dev->perm_addr, bp->mac_addr, 6);
@@ -8387,11 +8411,6 @@ bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
return 0;
error:
- if (bp->mips_firmware)
- release_firmware(bp->mips_firmware);
- if (bp->rv2p_firmware)
- release_firmware(bp->rv2p_firmware);
-
if (bp->regview)
iounmap(bp->regview);
pci_release_regions(pdev);
@@ -8412,11 +8431,6 @@ bnx2_remove_one(struct pci_dev *pdev)
del_timer_sync(&bp->timer);
cancel_work_sync(&bp->reset_task);
- if (bp->mips_firmware)
- release_firmware(bp->mips_firmware);
- if (bp->rv2p_firmware)
- release_firmware(bp->rv2p_firmware);
-
if (bp->regview)
iounmap(bp->regview);
@@ -8427,6 +8441,8 @@ bnx2_remove_one(struct pci_dev *pdev)
bp->flags &= ~BNX2_FLAG_AER_ENABLED;
}
+ bnx2_release_firmware(bp);
+
free_netdev(dev);
pci_release_regions(pdev);
--
1.7.4.4
^ permalink raw reply related
* Re: [PATCH 4/9] stmmac: add MMC support exported via ethtool (v2)
From: Giuseppe CAVALLARO @ 2011-08-31 5:52 UTC (permalink / raw)
To: Ben Hutchings; +Cc: netdev, David S. Miller
In-Reply-To: <1314718004.2752.15.camel@bwh-desktop>
Hello Ben
On 8/30/2011 5:26 PM, Ben Hutchings wrote:
> On Tue, 2011-08-30 at 16:20 +0200, Giuseppe CAVALLARO wrote:
>> This patch adds the MMC management counters support.
>> MMC module is an extension of the register address
>> space and all the hardware counters can be accessed
>> via ethtoo -S ethX.
>>
>> Note that, the MMC interrupts remain masked and the logic
>> to handle this kind of interrupt will be added later (if
>> actually useful).
> [...]
>> static void stmmac_ethtool_getdrvinfo(struct net_device *dev,
>> struct ethtool_drvinfo *info)
>> {
>> struct stmmac_priv *priv = netdev_priv(dev);
>>
>> - if (!priv->plat->has_gmac)
>> - strcpy(info->driver, MAC100_ETHTOOL_NAME);
>> - else
>> + info->n_stats = STMMAC_STATS_LEN;
>> +
>> + if (likely(priv->plat->has_gmac)) {
>
> Using likely() and unlikely() in ethtool operations seems like a
> pointless optimisation.
I agree with you that ethtool part is not critical and likely/unlikely
could be not used at all.
I had added them because today, AFAIK, the driver works on several
platforms with the GMAC and continues to support MAC10/100 (that I test
in my lab). I had thought that the likely/unlikely in ethtool can help
to emit instructions that causes optimize branch prediction to favor the
"likely" GMAC side.
At any rate, no problem to rework the patch deleting them or create a
new one on top of these.
>
>> strcpy(info->driver, GMAC_ETHTOOL_NAME);
>> + info->n_stats += STMMAC_MMC_STATS_LEN;
>> + } else
>> + strcpy(info->driver, MAC100_ETHTOOL_NAME);
>>
>> strcpy(info->version, DRV_MODULE_VERSION);
>> info->fw_version[0] = '\0';
>> - info->n_stats = STMMAC_STATS_LEN;
>> }
> [...]
>
> Don't bother initialising ethtool_drvinfo::n_stats. The ethtool core
> will do it by calling your get_sset_count implementation.
Ok! thanks I missed this.
As above, let me know if I have to resent the patches or create a new
patch for this fix too.
In the end, any other advice?
Regards
Peppe
>
> Ben.
>
^ permalink raw reply
* Re: slow performance on disk/network i/o full speed after drop_caches
From: Stefan Priebe - Profihost AG @ 2011-08-31 7:11 UTC (permalink / raw)
To: Zhu Yanhai
Cc: Wu Fengguang, Pekka Enberg, LKML, linux-mm@kvack.org,
Andrew Morton, Mel Gorman, Jens Axboe, Linux Netdev List
In-Reply-To: <4E573A99.4060309@profihost.ag>
Hi Fengguang,
Hi Yanhai,
> you're abssolutely corect zone_reclaim_mode is on - but why?
> There must be some linux software which switches it on.
>
> ~# grep 'zone_reclaim_mode' /etc/sysctl.* -r -i
> ~#
>
> also
> ~# grep 'zone_reclaim_mode' /etc/sysctl.* -r -i
> ~#
>
> tells us nothing.
>
> I've then read this:
>
> "zone_reclaim_mode is set during bootup to 1 if it is determined that
> pages from remote zones will cause a measurable performance reduction.
> The page allocator will then reclaim easily reusable pages (those page
> cache pages that are currently not used) before allocating off node pages."
>
> Why does the kernel do that here in our case on these machines.
Can nobody help why the kernel in this case set it to 1?
Stefan
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply
* Re: [patch net-next-2.6 1/2] net: allow to change carrier via sysfs
From: Jiri Pirko @ 2011-08-31 8:26 UTC (permalink / raw)
To: Michał Mirosław
Cc: netdev, davem, eric.dumazet, bhutchings, shemminger
In-Reply-To: <CAHXqBFJh0xjRYv_-2AzwAvpHOUfQ+pD_153qVtNA3Ybo9r3b=w@mail.gmail.com>
Tue, Aug 30, 2011 at 08:11:37PM CEST, mirqus@gmail.com wrote:
>2011/8/30 Jiri Pirko <jpirko@redhat.com>:
>> Allow to write to "carrier" attribute. Devices may implement ndo_change_carrier
>> callback to allow changing carrier from userspace.
>
>Do you expect drivers using implementation different than just calling
>netif_carrier_on/off? Or is it supposed to also e.g. power down PHYs?
Yes, generally it can be used also for en/disable phy, for testing
purposes if hw and driver would support it.
>
>BTW, I like this feature!
>
>Best Regards,
>Michał Mirosław
^ permalink raw reply
* Re: [patch net-next-2.6 1/2] net: allow to change carrier via sysfs
From: Jiri Pirko @ 2011-08-31 8:31 UTC (permalink / raw)
To: Stephen Hemminger
Cc: Michał Mirosław, netdev, davem, eric.dumazet,
bhutchings
In-Reply-To: <20110830112553.012ffa85@nehalam.ftrdhcpuser.net>
Tue, Aug 30, 2011 at 08:25:53PM CEST, shemminger@vyatta.com wrote:
>On Tue, 30 Aug 2011 20:11:37 +0200
>Michał Mirosław <mirqus@gmail.com> wrote:
>
>> 2011/8/30 Jiri Pirko <jpirko@redhat.com>:
>> > Allow to write to "carrier" attribute. Devices may implement ndo_change_carrier
>> > callback to allow changing carrier from userspace.
>>
>> Do you expect drivers using implementation different than just calling
>> netif_carrier_on/off? Or is it supposed to also e.g. power down PHYs?
>>
>> BTW, I like this feature!
>
>Ok for virtual devices, but please don't implement it in real hardware.
>There is already enough breakage in carrier management in applications.
>It also overlaps with operstate perhaps that is a more more complete
>solution.
Looking at operstate doc, I'm not sure what exactly do you mean by
"overlapping".
The main purpose of my patch is to give certain virt devices the
opportunity to emulate carrier loss. But I do not see reason why this
can't be implemented by real hw. Or course there should be explicitelly
documented the purpose of this feature.
Jirka
>
^ permalink raw reply
* Re: [patch net-next-2.6 1/2] net: allow to change carrier via sysfs
From: Michał Mirosław @ 2011-08-31 8:33 UTC (permalink / raw)
To: Jiri Pirko; +Cc: netdev, davem, eric.dumazet, bhutchings, shemminger
In-Reply-To: <20110831082655.GB2010@minipsycho.brq.redhat.com>
W dniu 31 sierpnia 2011 10:26 użytkownik Jiri Pirko <jpirko@redhat.com> napisał:
> Tue, Aug 30, 2011 at 08:11:37PM CEST, mirqus@gmail.com wrote:
>>2011/8/30 Jiri Pirko <jpirko@redhat.com>:
>>> Allow to write to "carrier" attribute. Devices may implement ndo_change_carrier
>>> callback to allow changing carrier from userspace.
>>Do you expect drivers using implementation different than just calling
>>netif_carrier_on/off? Or is it supposed to also e.g. power down PHYs?
> Yes, generally it can be used also for en/disable phy, for testing
> purposes if hw and driver would support it.
I'd like to see this working for GRE tunnel devices (for keepalive
daemon to be able to indicate to routing daemons whether tunnel is
really working) - implementation would be identical to dummy's case.
Should I prepare a patch or can I leave it to you?
Best Regards,
Michał Mirosław
^ permalink raw reply
* [PATCH 0/2] Dump the sock's security context
From: rongqing.li @ 2011-08-31 8:36 UTC (permalink / raw)
To: netdev, selinux, linux-security-module
-------
Any review would be much appreciated.
Comments:
--------
Add a netlink attribute INET_DIAG_SECCTX
Add a new netlink attribute INET_DIAG_SECCTX to dump the security
context of TCP sockets.
The element sk_security of struct sock represents the socket
security context ID, which is inherited from the parent process
when the socket is created.
but when SELinux type_transition rule is applied to socket, or
application sets /proc/xxx/attr/createsock, the socket security
context would be different from the creating process. For these
conditions, the "netstat -Z" would return wrong value, since
"netstat -Z" only returns the process security context as socket
process security.
The application to verify the netlink new attribute.
------
See attached file
test:
--------
1. Enable SELinux when compile and startup .
root@qemu-host:/root> ./printsocketsec
inode:7141 system_u:system_r:rpcbind_t:s0
inode:7136 system_u:system_r:rpcbind_t:s0
inode:7604 system_u:system_r:initrc_t:s0
inode:7227 system_u:system_r:rpcd_t:s0
inode:7471 system_u:system_r:sshd_t:s0-s0:c0.c1023
inode:7469 system_u:system_r:sshd_t:s0-s0:c0.c1023
inode:7552 system_u:system_r:sendmail_t:s0
inode:7348 system_u:system_r:initrc_t:s0
inode:7553 system_u:system_r:sendmail_t:s0
root@qemu-host:/root>
2. Disable SELinux when startup.
root@qemu-host:/root> ./printsocketsec
inode:3221
inode:2942
inode:2861
inode:3256
inode:3156
inode:3220
inode:3060
root@qemu-host:/root>
3. Disable SELinux when compile and startup
root@qemu-host:/root> ./printsocketsec
inode:3221
inode:2942
inode:2861
inode:3256
inode:3156
inode:3220
inode:3060
root@qemu-host:/root>
^ permalink raw reply
* [PATCH 1/2] Define security_sk_getsecctx
From: rongqing.li @ 2011-08-31 8:36 UTC (permalink / raw)
To: netdev, selinux, linux-security-module
In-Reply-To: <1314779777-12669-1-git-send-email-rongqing.li@windriver.com>
From: Roy.Li <rongqing.li@windriver.com>
Define security_sk_getsecctx to return the security
context of a sock.
Signed-off-by: Roy.Li <rongqing.li@windriver.com>
---
include/linux/security.h | 13 +++++++++++++
security/capability.c | 6 ++++++
security/security.c | 6 ++++++
security/selinux/hooks.c | 9 +++++++++
4 files changed, 34 insertions(+), 0 deletions(-)
diff --git a/include/linux/security.h b/include/linux/security.h
index ebd2a53..6bb8e0c 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -959,6 +959,12 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
* @sk_getsecid:
* Retrieve the LSM-specific secid for the sock to enable caching of network
* authorizations.
+ * @sk_getsecctx:
+ * Returns a string containing sock security context information
+ * @sk whom we wish to get the security context.
+ * @ctx is the address of the pointer to where to place the allocated
+ * security context.
+ * @ctxlen points to the value of the length of the security context.
* @sock_graft:
* Sets the socket's isec sid to the sock's sid.
* @inet_conn_request:
@@ -1600,6 +1606,7 @@ struct security_operations {
void (*sk_free_security) (struct sock *sk);
void (*sk_clone_security) (const struct sock *sk, struct sock *newsk);
void (*sk_getsecid) (struct sock *sk, u32 *secid);
+ int (*sk_getsecctx) (struct sock *sk, void **ctx, u32 *ctxlen);
void (*sock_graft) (struct sock *sk, struct socket *parent);
int (*inet_conn_request) (struct sock *sk, struct sk_buff *skb,
struct request_sock *req);
@@ -2574,6 +2581,7 @@ void security_secmark_refcount_dec(void);
int security_tun_dev_create(void);
void security_tun_dev_post_create(struct sock *sk);
int security_tun_dev_attach(struct sock *sk);
+int security_sk_getsecctx(struct sock *sk, void **ctx, u32 *ctxlen);
#else /* CONFIG_SECURITY_NETWORK */
static inline int security_unix_stream_connect(struct sock *sock,
@@ -2751,6 +2759,11 @@ static inline int security_tun_dev_attach(struct sock *sk)
{
return 0;
}
+
+static int security_sk_getsecctx(struct sock *sk, void **ctx, u32 *ctxlen)
+{
+ return -EOPNOTSUPP;
+}
#endif /* CONFIG_SECURITY_NETWORK */
#ifdef CONFIG_SECURITY_NETWORK_XFRM
diff --git a/security/capability.c b/security/capability.c
index 2984ea4..89256a6 100644
--- a/security/capability.c
+++ b/security/capability.c
@@ -664,6 +664,11 @@ static void cap_sk_getsecid(struct sock *sk, u32 *secid)
{
}
+static int cap_sk_getsecctx(struct sock *sk, void **ctx, u32 *ctxlen)
+{
+ return 0;
+}
+
static void cap_sock_graft(struct sock *sk, struct socket *parent)
{
}
@@ -1032,6 +1037,7 @@ void __init security_fixup_ops(struct security_operations *ops)
set_to_cap_if_null(ops, sk_free_security);
set_to_cap_if_null(ops, sk_clone_security);
set_to_cap_if_null(ops, sk_getsecid);
+ set_to_cap_if_null(ops, sk_getsecctx);
set_to_cap_if_null(ops, sock_graft);
set_to_cap_if_null(ops, inet_conn_request);
set_to_cap_if_null(ops, inet_csk_clone);
diff --git a/security/security.c b/security/security.c
index 0e4fccf..a939f5c 100644
--- a/security/security.c
+++ b/security/security.c
@@ -757,6 +757,12 @@ void security_task_getsecid(struct task_struct *p, u32 *secid)
}
EXPORT_SYMBOL(security_task_getsecid);
+int security_sk_getsecctx(struct sock *sk, void **ctx, u32 *ctxlen)
+{
+ return security_ops->sk_getsecctx(sk, ctx, ctxlen);
+}
+EXPORT_SYMBOL(security_sk_getsecctx);
+
int security_task_setnice(struct task_struct *p, int nice)
{
return security_ops->task_setnice(p, nice);
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 266a229..6e96f01 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -4284,6 +4284,14 @@ static void selinux_sk_getsecid(struct sock *sk, u32 *secid)
}
}
+static int selinux_sk_getsecctx(struct sock *sk, void **ctx, u32 *ctxlen)
+{
+ u32 secid;
+
+ selinux_sk_getsecid(sk, &secid);
+ return security_sid_to_context(secid, ctx, ctxlen);
+}
+
static void selinux_sock_graft(struct sock *sk, struct socket *parent)
{
struct inode_security_struct *isec = SOCK_INODE(parent)->i_security;
@@ -5613,6 +5621,7 @@ static struct security_operations selinux_ops = {
.sk_free_security = selinux_sk_free_security,
.sk_clone_security = selinux_sk_clone_security,
.sk_getsecid = selinux_sk_getsecid,
+ .sk_getsecctx = selinux_sk_getsecctx,
.sock_graft = selinux_sock_graft,
.inet_conn_request = selinux_inet_conn_request,
.inet_csk_clone = selinux_inet_csk_clone,
--
1.7.1
^ permalink raw reply related
* [PATCH 2/2] Add a netlink attribute INET_DIAG_SECCTX
From: rongqing.li @ 2011-08-31 8:36 UTC (permalink / raw)
To: netdev, selinux, linux-security-module
In-Reply-To: <1314779777-12669-1-git-send-email-rongqing.li@windriver.com>
From: Roy.Li <rongqing.li@windriver.com>
Add a new netlink attribute INET_DIAG_SECCTX to dump the security
context of TCP sockets.
The element sk_security of struct sock represents the socket
security context ID, which is inherited from the parent process
when the socket is created.
but when SELinux type_transition rule is applied to socket, or
application sets /proc/xxx/attr/createsock, the socket security
context would be different from the creating process. For these
conditions, the "netstat -Z" will return wrong value, since
"netstat -Z" only returns the process security context as socket
process security.
Signed-off-by: Roy.Li <rongqing.li@windriver.com>
---
include/linux/inet_diag.h | 3 ++-
net/ipv4/inet_diag.c | 38 +++++++++++++++++++++++++++++++++-----
2 files changed, 35 insertions(+), 6 deletions(-)
diff --git a/include/linux/inet_diag.h b/include/linux/inet_diag.h
index bc8c490..00382b4 100644
--- a/include/linux/inet_diag.h
+++ b/include/linux/inet_diag.h
@@ -97,9 +97,10 @@ enum {
INET_DIAG_INFO,
INET_DIAG_VEGASINFO,
INET_DIAG_CONG,
+ INET_DIAG_SECCTX,
};
-#define INET_DIAG_MAX INET_DIAG_CONG
+#define INET_DIAG_MAX INET_DIAG_SECCTX
/* INET_DIAG_MEM */
diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c
index 389a2e6..1faf752 100644
--- a/net/ipv4/inet_diag.c
+++ b/net/ipv4/inet_diag.c
@@ -34,6 +34,8 @@
#include <linux/inet_diag.h>
+#define MAX_SECCTX_LEN 128
+
static const struct inet_diag_handler **inet_diag_table;
struct inet_diag_entry {
@@ -108,6 +110,25 @@ static int inet_csk_diag_fill(struct sock *sk,
icsk->icsk_ca_ops->name);
}
+ if (ext & (1 << (INET_DIAG_SECCTX - 1))) {
+ u32 ctxlen = 0;
+ void *secctx;
+ int error;
+
+ error = security_sk_getsecctx(sk, &secctx, &ctxlen);
+
+ if (!error && ctxlen) {
+ if (ctxlen < MAX_SECCTX_LEN) {
+ strcpy(INET_DIAG_PUT(skb, INET_DIAG_SECCTX,
+ ctxlen + 1), secctx);
+ } else {
+ strcpy(INET_DIAG_PUT(skb, INET_DIAG_SECCTX,
+ 2), "-");
+ }
+ security_release_secctx(secctx, ctxlen);
+ }
+ }
+
r->idiag_family = sk->sk_family;
r->idiag_state = sk->sk_state;
r->idiag_timer = 0;
@@ -246,7 +267,7 @@ static int sk_diag_fill(struct sock *sk, struct sk_buff *skb,
static int inet_diag_get_exact(struct sk_buff *in_skb,
const struct nlmsghdr *nlh)
{
- int err;
+ int err, len;
struct sock *sk;
struct inet_diag_req *req = NLMSG_DATA(nlh);
struct sk_buff *rep;
@@ -293,10 +314,17 @@ static int inet_diag_get_exact(struct sk_buff *in_skb,
goto out;
err = -ENOMEM;
- rep = alloc_skb(NLMSG_SPACE((sizeof(struct inet_diag_msg) +
- sizeof(struct inet_diag_meminfo) +
- handler->idiag_info_size + 64)),
- GFP_KERNEL);
+ len = sizeof(struct inet_diag_msg) + 64;
+
+ len += (req->idiag_ext & (1 << (INET_DIAG_MEMINFO - 1))) ?
+ sizeof(struct inet_diag_meminfo) : 0;
+ len += (req->idiag_ext & (1 << (INET_DIAG_INFO - 1))) ?
+ handler->idiag_info_size : 0;
+ len += (req->idiag_ext & (1 << (INET_DIAG_SECCTX - 1))) ?
+ MAX_SECCTX_LEN : 0;
+
+ rep = alloc_skb(NLMSG_SPACE(len), GFP_KERNEL);
+
if (!rep)
goto out;
--
1.7.1
^ permalink raw reply related
* Re: [PATCH 0/2] Dump the sock's security context
From: Rongqing Li @ 2011-08-31 8:38 UTC (permalink / raw)
To: rongqing.li; +Cc: netdev, selinux, linux-security-module
In-Reply-To: <1314779777-12669-1-git-send-email-rongqing.li@windriver.com>
[-- Attachment #1: Type: text/plain, Size: 2153 bytes --]
On 08/31/2011 04:36 PM, rongqing.li@windriver.com wrote:
> -------
> Any review would be much appreciated.
>
> Comments:
> --------
> Add a netlink attribute INET_DIAG_SECCTX
>
> Add a new netlink attribute INET_DIAG_SECCTX to dump the security
> context of TCP sockets.
>
> The element sk_security of struct sock represents the socket
> security context ID, which is inherited from the parent process
> when the socket is created.
>
> but when SELinux type_transition rule is applied to socket, or
> application sets /proc/xxx/attr/createsock, the socket security
> context would be different from the creating process. For these
> conditions, the "netstat -Z" would return wrong value, since
> "netstat -Z" only returns the process security context as socket
> process security.
>
>
> The application to verify the netlink new attribute.
> ------
> See attached file
>
> test:
> --------
> 1. Enable SELinux when compile and startup .
> root@qemu-host:/root> ./printsocketsec
> inode:7141 system_u:system_r:rpcbind_t:s0
> inode:7136 system_u:system_r:rpcbind_t:s0
> inode:7604 system_u:system_r:initrc_t:s0
> inode:7227 system_u:system_r:rpcd_t:s0
> inode:7471 system_u:system_r:sshd_t:s0-s0:c0.c1023
> inode:7469 system_u:system_r:sshd_t:s0-s0:c0.c1023
> inode:7552 system_u:system_r:sendmail_t:s0
> inode:7348 system_u:system_r:initrc_t:s0
> inode:7553 system_u:system_r:sendmail_t:s0
> root@qemu-host:/root>
>
> 2. Disable SELinux when startup.
> root@qemu-host:/root> ./printsocketsec
> inode:3221
> inode:2942
> inode:2861
> inode:3256
> inode:3156
> inode:3220
> inode:3060
> root@qemu-host:/root>
>
> 3. Disable SELinux when compile and startup
> root@qemu-host:/root> ./printsocketsec
> inode:3221
> inode:2942
> inode:2861
> inode:3256
> inode:3156
> inode:3220
> inode:3060
> root@qemu-host:/root>
> --
> 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
>
--
Best Reagrds,
Roy | RongQing Li
[-- Attachment #2: printsocketsec.c --]
[-- Type: text/x-csrc, Size: 2876 bytes --]
#include <stdio.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <errno.h>
#include "libnetlink.h"
#include <netinet/tcp.h>
#include <linux/inet_diag.h>
enum {
SS_UNKNOWN,
SS_ESTABLISHED,
SS_SYN_SENT,
SS_SYN_RECV,
SS_FIN_WAIT1,
SS_FIN_WAIT2,
SS_TIME_WAIT,
SS_CLOSE,
SS_CLOSE_WAIT,
SS_LAST_ACK,
SS_LISTEN,
SS_CLOSING,
SS_MAX
};
#define SS_ALL ((1<<SS_MAX)-1)
/*The INET_DIAG_SECCTX should be defined in inet_diag.h at last,
To simply the test, I define it locally*/
#define INET_DIAG_SECCTX (INET_DIAG_CONG+1)
#define LOCAL_MAX INET_DIAG_SECCTX+1
void tcp_show_info(const struct nlmsghdr *nlh, struct inet_diag_msg *r)
{
struct rtattr * tb[ LOCAL_MAX + 1];
printf(" inode:%u", r->idiag_inode);
parse_rtattr(tb, LOCAL_MAX, (struct rtattr*)(r+1),
nlh->nlmsg_len - NLMSG_LENGTH(sizeof(*r)));
if (tb[INET_DIAG_SECCTX])
printf(" %s", (char *) RTA_DATA(tb[INET_DIAG_SECCTX]));
printf("\n");
}
static int tcp_show_netlink( int socktype)
{
int fd;
struct sockaddr_nl nladdr;
struct {
struct nlmsghdr nlh;
struct inet_diag_req r;
} req;
struct msghdr msg;
struct rtattr rta;
char buf[8192];
struct iovec iov[3];
if ((fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_INET_DIAG)) < 0)
return -1;
memset(&nladdr, 0, sizeof(nladdr));
nladdr.nl_family = AF_NETLINK;
req.nlh.nlmsg_len = sizeof(req);
req.nlh.nlmsg_type = socktype;
req.nlh.nlmsg_flags = NLM_F_ROOT|NLM_F_MATCH|NLM_F_REQUEST;
req.nlh.nlmsg_pid = 0;
req.nlh.nlmsg_seq = 123456;
memset(&req.r, 0, sizeof(req.r));
req.r.idiag_family = AF_INET;
req.r.idiag_states = SS_ALL;
req.r.idiag_ext |= (1<<(INET_DIAG_SECCTX-1));
iov[0] = (struct iovec){
.iov_base = &req,
.iov_len = sizeof(req)
};
msg = (struct msghdr) {
.msg_name = (void*)&nladdr,
.msg_namelen = sizeof(nladdr),
.msg_iov = iov,
.msg_iovlen = 1,
};
if (sendmsg(fd, &msg, 0) < 0)
return -1;
iov[0] = (struct iovec){
.iov_base = buf,
.iov_len = sizeof(buf)
};
while (1) {
int status;
struct nlmsghdr *h;
msg = (struct msghdr) {
(void*)&nladdr, sizeof(nladdr),
iov, 1,
NULL, 0,
0
};
status = recvmsg(fd, &msg, 0);
if (status < 0) {
if (errno == EINTR)
continue;
perror("OVERRUN");
continue;
}
if (status == 0) {
fprintf(stderr, "EOF on netlink\n");
return 0;
}
h = (struct nlmsghdr*)buf;
while (NLMSG_OK(h, status)) {
struct inet_diag_msg *r = NLMSG_DATA(h);
if (/*h->nlmsg_pid != rth->local.nl_pid ||*/
h->nlmsg_seq != 123456)
goto skip_it;
if (h->nlmsg_type == NLMSG_DONE)
return 0;
if (h->nlmsg_type == NLMSG_ERROR)
return 0;
tcp_show_info(h, r);
skip_it:
h = NLMSG_NEXT(h, status);
}
}
return 0;
}
void main()
{
tcp_show_netlink( TCPDIAG_GETSOCK);
}
^ permalink raw reply
* Re: [patch net-next-2.6 1/2] net: allow to change carrier via sysfs
From: Jiri Pirko @ 2011-08-31 8:45 UTC (permalink / raw)
To: Michał Mirosław
Cc: netdev, davem, eric.dumazet, bhutchings, shemminger
In-Reply-To: <CAHXqBFJpSZNhkur7QNYbjG-=Bkq2HtHKEHsn+H3TnEJ5NezJoA@mail.gmail.com>
Wed, Aug 31, 2011 at 10:33:50AM CEST, mirqus@gmail.com wrote:
>W dniu 31 sierpnia 2011 10:26 użytkownik Jiri Pirko <jpirko@redhat.com> napisał:
>> Tue, Aug 30, 2011 at 08:11:37PM CEST, mirqus@gmail.com wrote:
>>>2011/8/30 Jiri Pirko <jpirko@redhat.com>:
>>>> Allow to write to "carrier" attribute. Devices may implement ndo_change_carrier
>>>> callback to allow changing carrier from userspace.
>>>Do you expect drivers using implementation different than just calling
>>>netif_carrier_on/off? Or is it supposed to also e.g. power down PHYs?
>> Yes, generally it can be used also for en/disable phy, for testing
>> purposes if hw and driver would support it.
>
>I'd like to see this working for GRE tunnel devices (for keepalive
>daemon to be able to indicate to routing daemons whether tunnel is
>really working) - implementation would be identical to dummy's case.
>Should I prepare a patch or can I leave it to you?
Ok, I can include it to this patchset (I'm going to repost first patch
anyway)
>
>Best Regards,
>Michał Mirosław
^ permalink raw reply
* [PATCH net-next] net: linkwatch: allow vlans to get carrier changes faster
From: Eric Dumazet @ 2011-08-31 9:31 UTC (permalink / raw)
To: HAYASAKA Mitsuo
Cc: Herbert Xu, Stephen Hemminger, Patrick McHardy, David S. Miller,
MichałMirosław, Tom Herbert, Jesse Gross, netdev,
linux-kernel, yrl.pp-manager.tt
In-Reply-To: <1314540589.3036.12.camel@edumazet-laptop>
There is a time-lag of IFF_RUNNING flag consistency between vlan and
real devices when the real devices are in problem such as link or cable
broken.
This leads to a degradation of Availability such as a delay of failover
in HA systems using vlan since the detection of the problem at real
device is delayed.
We can avoid the linkwatch delay (~1 sec) for devices linked to another
ones, since delay is already done for the realdev.
Based on a previous patch from Mitsuo Hayasaka
Reported-by: Mitsuo Hayasaka <mitsuo.hayasaka.hu@hitachi.com>
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Patrick McHardy <kaber@trash.net>
Cc: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
Cc: Tom Herbert <therbert@google.com>
Cc: Stephen Hemminger <shemminger@vyatta.com>
Cc: Jesse Gross <jesse@nicira.com>
---
net/core/link_watch.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/net/core/link_watch.c b/net/core/link_watch.c
index 357bd4e..c3519c6 100644
--- a/net/core/link_watch.c
+++ b/net/core/link_watch.c
@@ -78,8 +78,13 @@ static void rfc2863_policy(struct net_device *dev)
static bool linkwatch_urgent_event(struct net_device *dev)
{
- return netif_running(dev) && netif_carrier_ok(dev) &&
- qdisc_tx_changing(dev);
+ if (!netif_running(dev))
+ return false;
+
+ if (dev->ifindex != dev->iflink)
+ return true;
+
+ return netif_carrier_ok(dev) && qdisc_tx_changing(dev);
}
^ permalink raw reply related
* [PATCH 1/2] Remove requirement to set tx-usecs-irq for shared channels when modifying coalescing parameters
From: Ripduman Sohan @ 2011-08-31 9:38 UTC (permalink / raw)
To: linux-net-drivers, shodgson, bhutchings; +Cc: netdev, Ripduman Sohan
Shared TX/RX channels possess a single channel timer controlled by the
rx-usecs-irq parameter. Changing coalescing parameters required
explicitly setting the tx-usecs-irq parameter to 0. Ethtool (to HEAD
of tree) does not do this and instead retrieves and re-submits the
current tx-usecs-irq value resulting in an unsupported operation
error. I found this behaviour counter-intuitive and was only able to
work out correct moderation parameters by studying the driver code.
This patch relaxes the requirement to set tx-usecs-irq to 0 by only
erring if the presented tx-usecs-irq value differs from the current
value. I acknowledge, however, that there may be existing scripts
relying on the old behaviour and so this condition is only triggered
if a value for tx-usecs-irq is actually presented.
---
drivers/net/sfc/efx.c | 6 +++---
drivers/net/sfc/efx.h | 1 +
drivers/net/sfc/ethtool.c | 4 +++-
3 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/net/sfc/efx.c b/drivers/net/sfc/efx.c
index faca764..9a313cd 100644
--- a/drivers/net/sfc/efx.c
+++ b/drivers/net/sfc/efx.c
@@ -1556,7 +1556,7 @@ static void efx_remove_all(struct efx_nic *efx)
*
**************************************************************************/
-static unsigned irq_mod_ticks(int usecs, int resolution)
+unsigned efx_irq_mod_ticks(int usecs, int resolution)
{
if (usecs <= 0)
return 0; /* cannot receive interrupts ahead of time :-) */
@@ -1570,8 +1570,8 @@ void efx_init_irq_moderation(struct efx_nic *efx, int tx_usecs, int rx_usecs,
bool rx_adaptive)
{
struct efx_channel *channel;
- unsigned tx_ticks = irq_mod_ticks(tx_usecs, EFX_IRQ_MOD_RESOLUTION);
- unsigned rx_ticks = irq_mod_ticks(rx_usecs, EFX_IRQ_MOD_RESOLUTION);
+ unsigned tx_ticks = efx_irq_mod_ticks(tx_usecs, EFX_IRQ_MOD_RESOLUTION);
+ unsigned rx_ticks = efx_irq_mod_ticks(rx_usecs, EFX_IRQ_MOD_RESOLUTION);
EFX_ASSERT_RESET_SERIALISED(efx);
diff --git a/drivers/net/sfc/efx.h b/drivers/net/sfc/efx.h
index b0d1209..ddfcc7e 100644
--- a/drivers/net/sfc/efx.h
+++ b/drivers/net/sfc/efx.h
@@ -113,6 +113,7 @@ extern int efx_reset_up(struct efx_nic *efx, enum reset_type method, bool ok);
extern void efx_schedule_reset(struct efx_nic *efx, enum reset_type type);
extern void efx_init_irq_moderation(struct efx_nic *efx, int tx_usecs,
int rx_usecs, bool rx_adaptive);
+extern unsigned efx_irq_mod_ticks(int usecs, int resolution);
/* Dummy PHY ops for PHY drivers */
extern int efx_port_dummy_op_int(struct efx_nic *efx);
diff --git a/drivers/net/sfc/ethtool.c b/drivers/net/sfc/ethtool.c
index bc4643a..0a52447 100644
--- a/drivers/net/sfc/ethtool.c
+++ b/drivers/net/sfc/ethtool.c
@@ -644,7 +644,9 @@ static int efx_ethtool_set_coalesce(struct net_device *net_dev,
efx_for_each_channel(channel, efx) {
if (efx_channel_has_rx_queue(channel) &&
efx_channel_has_tx_queues(channel) &&
- tx_usecs) {
+ tx_usecs &&
+ efx_irq_mod_ticks(tx_usecs, EFX_IRQ_MOD_RESOLUTION) !=
+ channel->irq_moderation) {
netif_err(efx, drv, efx->net_dev, "Channel is shared. "
"Only RX coalescing may be set\n");
return -EOPNOTSUPP;
--
1.7.1
^ permalink raw reply related
* [PATCH 1/2] sfc: Remove requirement to set tx-usecs-irq for shared channels when modifying coalescing parameters
From: Ripduman Sohan @ 2011-08-31 9:52 UTC (permalink / raw)
To: linux-net-drivers, shodgson, bhutchings; +Cc: netdev, Ripduman Sohan
Shared TX/RX channels possess a single channel timer controlled by the
rx-usecs-irq parameter. Changing coalescing parameters required
explicitly setting the tx-usecs-irq parameter to 0. Ethtool (to HEAD
of tree) does not do this and instead retrieves and re-submits the
current tx-usecs-irq value resulting in an unsupported operation
error. I found this behaviour counter-intuitive and was only able to
work out correct moderation parameters by studying the driver code.
This patch relaxes the requirement to set tx-usecs-irq to 0 by only
erring if the presented tx-usecs-irq value differs from the current
value. I acknowledge, however, that there may be existing scripts
relying on the old behaviour and so this condition is only triggered
if a value for tx-usecs-irq is actually presented.
---
drivers/net/sfc/efx.c | 6 +++---
drivers/net/sfc/efx.h | 1 +
drivers/net/sfc/ethtool.c | 4 +++-
3 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/net/sfc/efx.c b/drivers/net/sfc/efx.c
index faca764..9a313cd 100644
--- a/drivers/net/sfc/efx.c
+++ b/drivers/net/sfc/efx.c
@@ -1556,7 +1556,7 @@ static void efx_remove_all(struct efx_nic *efx)
*
**************************************************************************/
-static unsigned irq_mod_ticks(int usecs, int resolution)
+unsigned efx_irq_mod_ticks(int usecs, int resolution)
{
if (usecs <= 0)
return 0; /* cannot receive interrupts ahead of time :-) */
@@ -1570,8 +1570,8 @@ void efx_init_irq_moderation(struct efx_nic *efx, int tx_usecs, int rx_usecs,
bool rx_adaptive)
{
struct efx_channel *channel;
- unsigned tx_ticks = irq_mod_ticks(tx_usecs, EFX_IRQ_MOD_RESOLUTION);
- unsigned rx_ticks = irq_mod_ticks(rx_usecs, EFX_IRQ_MOD_RESOLUTION);
+ unsigned tx_ticks = efx_irq_mod_ticks(tx_usecs, EFX_IRQ_MOD_RESOLUTION);
+ unsigned rx_ticks = efx_irq_mod_ticks(rx_usecs, EFX_IRQ_MOD_RESOLUTION);
EFX_ASSERT_RESET_SERIALISED(efx);
diff --git a/drivers/net/sfc/efx.h b/drivers/net/sfc/efx.h
index b0d1209..ddfcc7e 100644
--- a/drivers/net/sfc/efx.h
+++ b/drivers/net/sfc/efx.h
@@ -113,6 +113,7 @@ extern int efx_reset_up(struct efx_nic *efx, enum reset_type method, bool ok);
extern void efx_schedule_reset(struct efx_nic *efx, enum reset_type type);
extern void efx_init_irq_moderation(struct efx_nic *efx, int tx_usecs,
int rx_usecs, bool rx_adaptive);
+extern unsigned efx_irq_mod_ticks(int usecs, int resolution);
/* Dummy PHY ops for PHY drivers */
extern int efx_port_dummy_op_int(struct efx_nic *efx);
diff --git a/drivers/net/sfc/ethtool.c b/drivers/net/sfc/ethtool.c
index bc4643a..0a52447 100644
--- a/drivers/net/sfc/ethtool.c
+++ b/drivers/net/sfc/ethtool.c
@@ -644,7 +644,9 @@ static int efx_ethtool_set_coalesce(struct net_device *net_dev,
efx_for_each_channel(channel, efx) {
if (efx_channel_has_rx_queue(channel) &&
efx_channel_has_tx_queues(channel) &&
- tx_usecs) {
+ tx_usecs &&
+ efx_irq_mod_ticks(tx_usecs, EFX_IRQ_MOD_RESOLUTION) !=
+ channel->irq_moderation) {
netif_err(efx, drv, efx->net_dev, "Channel is shared. "
"Only RX coalescing may be set\n");
return -EOPNOTSUPP;
--
1.7.1
^ permalink raw reply related
* [PATCH 2/2] sfc: Report correct tx-usecs-irq value when driver is loaded with separate_tx_channels set
From: Ripduman Sohan @ 2011-08-31 9:53 UTC (permalink / raw)
To: linux-net-drivers, shodgson, bhutchings; +Cc: netdev, Ripduman Sohan
If the driver is loaded with the separate_tx_channels parameter set it
incorrectly reports TX moderation as 0 usecs regardless of the current
value. This patch fixes this oversight.
---
drivers/net/sfc/ethtool.c | 7 ++-----
1 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/net/sfc/ethtool.c b/drivers/net/sfc/ethtool.c
index 0a52447..dac0a84 100644
--- a/drivers/net/sfc/ethtool.c
+++ b/drivers/net/sfc/ethtool.c
@@ -600,11 +600,8 @@ static int efx_ethtool_get_coalesce(struct net_device *net_dev,
if (!efx_channel_has_tx_queues(channel))
continue;
if (channel->irq_moderation < coalesce->tx_coalesce_usecs_irq) {
- if (channel->channel < efx->n_rx_channels)
- coalesce->tx_coalesce_usecs_irq =
- channel->irq_moderation;
- else
- coalesce->tx_coalesce_usecs_irq = 0;
+ coalesce->tx_coalesce_usecs_irq =
+ channel->irq_moderation;
}
}
--
1.7.1
^ permalink raw reply related
* [PATCH 2/2] Report correct tx-usecs-irq value when driver is loaded with separate_tx_channels set
From: Ripduman Sohan @ 2011-08-31 9:38 UTC (permalink / raw)
To: linux-net-drivers, shodgson, bhutchings; +Cc: netdev, Ripduman Sohan
If the driver is loaded with the separate_tx_channels parameter set it
incorrectly reports TX moderation as 0 usecs regardless of the current
value. This patch fixes this oversight.
---
drivers/net/sfc/ethtool.c | 7 ++-----
1 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/net/sfc/ethtool.c b/drivers/net/sfc/ethtool.c
index 0a52447..dac0a84 100644
--- a/drivers/net/sfc/ethtool.c
+++ b/drivers/net/sfc/ethtool.c
@@ -600,11 +600,8 @@ static int efx_ethtool_get_coalesce(struct net_device *net_dev,
if (!efx_channel_has_tx_queues(channel))
continue;
if (channel->irq_moderation < coalesce->tx_coalesce_usecs_irq) {
- if (channel->channel < efx->n_rx_channels)
- coalesce->tx_coalesce_usecs_irq =
- channel->irq_moderation;
- else
- coalesce->tx_coalesce_usecs_irq = 0;
+ coalesce->tx_coalesce_usecs_irq =
+ channel->irq_moderation;
}
}
--
1.7.1
^ 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