From: Joe Perches <joe@perches.com>
To: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Cc: davem@davemloft.net, Dan Carpenter <dan.carpenter@oracle.com>,
netdev@vger.kernel.org, nhorman@redhat.com, sassmann@redhat.com,
jogreene@redhat.com
Subject: Re: [net] i40e: _MASK vs _SHIFT typo in i40e_handle_mdd_event()
Date: Wed, 22 Oct 2014 21:05:07 -0700 [thread overview]
Message-ID: <1414037107.15751.5.camel@perches.com> (raw)
In-Reply-To: <1414034544.15751.2.camel@perches.com>
On Wed, 2014-10-22 at 20:22 -0700, Joe Perches wrote:
> On Wed, 2014-10-22 at 20:06 -0700, Jeff Kirsher wrote:
> > We accidentally mask by the _SHIFT variable. It means that "event" is
> > always zero.
> []
> > diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
> []
> > @@ -6151,7 +6151,7 @@ static void i40e_handle_mdd_event(struct i40e_pf *pf)
> > I40E_GL_MDET_TX_PF_NUM_SHIFT;
> > u8 vf_num = (reg & I40E_GL_MDET_TX_VF_NUM_MASK) >>
> > I40E_GL_MDET_TX_VF_NUM_SHIFT;
> > - u8 event = (reg & I40E_GL_MDET_TX_EVENT_SHIFT) >>
> > + u8 event = (reg & I40E_GL_MDET_TX_EVENT_MASK) >>
> > I40E_GL_MDET_TX_EVENT_SHIFT;
> > u8 queue = (reg & I40E_GL_MDET_TX_QUEUE_MASK) >>
> > I40E_GL_MDET_TX_QUEUE_SHIFT;
> > @@ -6165,7 +6165,7 @@ static void i40e_handle_mdd_event(struct i40e_pf *pf)
> > if (reg & I40E_GL_MDET_RX_VALID_MASK) {
> > u8 func = (reg & I40E_GL_MDET_RX_FUNCTION_MASK) >>
> > I40E_GL_MDET_RX_FUNCTION_SHIFT;
> > - u8 event = (reg & I40E_GL_MDET_RX_EVENT_SHIFT) >>
> > + u8 event = (reg & I40E_GL_MDET_RX_EVENT_MASK) >>
> > I40E_GL_MDET_RX_EVENT_SHIFT;
> > u8 queue = (reg & I40E_GL_MDET_RX_QUEUE_MASK) >>
> > I40E_GL_MDET_RX_QUEUE_SHIFT;
>
> It might be useful to have a macro for that.
> Something like:
>
> #define GET_REG_VAL(reg, type) \
> ((reg & type##_MASK) >> type##_SHIFT)
>
> so these could become:
>
> u8 vf_num = GET_REG_VAL(reg, I40E_GL_MDET_TX_VF_NUM);
> u8 event = GET_REG_VAL(reg, I40E_GL_MDET_TX_EVENT);
>
> etc...
btw: Here's a defect:
Using the macro would also prevent this sort of precedence defect
diff --git a/drivers/net/ethernet/intel/i40e/i40e_common.c b/drivers/net/ethernet/intel/i40e/i40e_common.c
[]
@@ -809,8 +809,8 @@ i40e_status i40e_pf_reset(struct i40e_hw *hw)
* The grst delay value is in 100ms units, and we'll wait a
* couple counts longer to be sure we don't just miss the end.
*/
- grst_del = rd32(hw, I40E_GLGEN_RSTCTL) & I40E_GLGEN_RSTCTL_GRSTDEL_MASK
- >> I40E_GLGEN_RSTCTL_GRSTDEL_SHIFT;
bit shift has higher precedence than bitwise &
next prev parent reply other threads:[~2014-10-23 4:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-23 3:06 [net] i40e: _MASK vs _SHIFT typo in i40e_handle_mdd_event() Jeff Kirsher
2014-10-23 3:22 ` Joe Perches
2014-10-23 4:05 ` Joe Perches [this message]
2014-10-25 20:51 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1414037107.15751.5.camel@perches.com \
--to=joe@perches.com \
--cc=dan.carpenter@oracle.com \
--cc=davem@davemloft.net \
--cc=jeffrey.t.kirsher@intel.com \
--cc=jogreene@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=nhorman@redhat.com \
--cc=sassmann@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).