net/ixgbe/base: fix check for NACK
authorXiao Wang <xiao.w.wang@intel.com>
Sun, 25 Sep 2016 08:59:55 +0000 (16:59 +0800)
committerBruce Richardson <bruce.richardson@intel.com>
Fri, 30 Sep 2016 10:27:18 +0000 (12:27 +0200)
Previously we checked return buffer for
(IXGBE_VF_SET_MACVLAN | IXGBE_VT_MSGTYPE_NACK), but this would not
work if index is not 0 and as a result NACK will not be detected.

Fixes: af75078fece3 ("first public release")

Signed-off-by: Xiao Wang <xiao.w.wang@intel.com>
Acked-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
drivers/net/ixgbe/base/ixgbe_vf.c

index c0fedea..e5f3771 100644 (file)
@@ -530,7 +530,7 @@ s32 ixgbe_get_mac_addr_vf(struct ixgbe_hw *hw, u8 *mac_addr)
 s32 ixgbevf_set_uc_addr_vf(struct ixgbe_hw *hw, u32 index, u8 *addr)
 {
        struct ixgbe_mbx_info *mbx = &hw->mbx;
-       u32 msgbuf[3];
+       u32 msgbuf[3], msgbuf_chk;
        u8 *msg_addr = (u8 *)(&msgbuf[1]);
        s32 ret_val;
 
@@ -543,18 +543,19 @@ s32 ixgbevf_set_uc_addr_vf(struct ixgbe_hw *hw, u32 index, u8 *addr)
         */
        msgbuf[0] |= index << IXGBE_VT_MSGINFO_SHIFT;
        msgbuf[0] |= IXGBE_VF_SET_MACVLAN;
+       msgbuf_chk = msgbuf[0];
        if (addr)
                memcpy(msg_addr, addr, 6);
        ret_val = mbx->ops.write_posted(hw, msgbuf, 3, 0);
 
        if (!ret_val)
                ret_val = mbx->ops.read_posted(hw, msgbuf, 3, 0);
+       if (!ret_val) {
+               msgbuf[0] &= ~IXGBE_VT_MSGTYPE_CTS;
 
-       msgbuf[0] &= ~IXGBE_VT_MSGTYPE_CTS;
-
-       if (!ret_val)
-               if (msgbuf[0] == (IXGBE_VF_SET_MACVLAN | IXGBE_VT_MSGTYPE_NACK))
-                       ret_val = IXGBE_ERR_OUT_OF_MEM;
+               if (msgbuf[0] == (msgbuf_chk | IXGBE_VT_MSGTYPE_NACK))
+                       return IXGBE_ERR_OUT_OF_MEM;
+       }
 
        return ret_val;
 }