ixgbe/base: abstract out link read/write
[dpdk.git] / drivers / net / ixgbe / base / ixgbe_82599.c
index f0deb59..154c1f1 100644 (file)
@@ -378,8 +378,8 @@ s32 ixgbe_init_ops_82599(struct ixgbe_hw *hw)
        mac->max_tx_queues      = IXGBE_82599_MAX_TX_QUEUES;
        mac->max_msix_vectors   = ixgbe_get_pcie_msix_count_generic(hw);
 
-       mac->arc_subsystem_valid = (IXGBE_READ_REG(hw, IXGBE_FWSM) &
-                                  IXGBE_FWSM_MODE_MASK) ? true : false;
+       mac->arc_subsystem_valid = !!(IXGBE_READ_REG(hw, IXGBE_FWSM_BY_MAC(hw))
+                                     & IXGBE_FWSM_MODE_MASK);
 
        hw->mbx.ops.init_params = ixgbe_init_mbx_params_pf;
 
@@ -1369,7 +1369,7 @@ s32 ixgbe_init_fdir_perfect_82599(struct ixgbe_hw *hw, u32 fdirctrl,
         * Continue setup of fdirctrl register bits:
         *  Turn perfect match filtering on
         *  Report hash in RSS field of Rx wb descriptor
-        *  Initialize the drop queue
+        *  Initialize the drop queue to queue 127
         *  Move the flexible bytes to use the ethertype - shift 6 words
         *  Set the maximum length per hash bucket to 0xA filters
         *  Send interrupt when 64 (0x4 * 16) filters are left
@@ -1391,6 +1391,40 @@ s32 ixgbe_init_fdir_perfect_82599(struct ixgbe_hw *hw, u32 fdirctrl,
        return IXGBE_SUCCESS;
 }
 
+/**
+ *  ixgbe_set_fdir_drop_queue_82599 - Set Flow Director drop queue
+ *  @hw: pointer to hardware structure
+ *  @dropqueue: Rx queue index used for the dropped packets
+ **/
+void ixgbe_set_fdir_drop_queue_82599(struct ixgbe_hw *hw, u8 dropqueue)
+{
+       u32 fdirctrl;
+
+       DEBUGFUNC("ixgbe_set_fdir_drop_queue_82599");
+       /* Clear init done bit and drop queue field */
+       fdirctrl = IXGBE_READ_REG(hw, IXGBE_FDIRCTRL);
+       fdirctrl &= ~(IXGBE_FDIRCTRL_DROP_Q_MASK | IXGBE_FDIRCTRL_INIT_DONE);
+
+       /* Set drop queue */
+       fdirctrl |= (dropqueue << IXGBE_FDIRCTRL_DROP_Q_SHIFT);
+       if ((hw->mac.type == ixgbe_mac_X550) ||
+           (hw->mac.type == ixgbe_mac_X550EM_x) ||
+           (hw->mac.type == ixgbe_mac_X550EM_a))
+               fdirctrl |= IXGBE_FDIRCTRL_DROP_NO_MATCH;
+
+       IXGBE_WRITE_REG(hw, IXGBE_FDIRCMD,
+                       (IXGBE_READ_REG(hw, IXGBE_FDIRCMD) |
+                        IXGBE_FDIRCMD_CLEARHT));
+       IXGBE_WRITE_FLUSH(hw);
+       IXGBE_WRITE_REG(hw, IXGBE_FDIRCMD,
+                       (IXGBE_READ_REG(hw, IXGBE_FDIRCMD) &
+                        ~IXGBE_FDIRCMD_CLEARHT));
+       IXGBE_WRITE_FLUSH(hw);
+
+       /* write hashes and fdirctrl register, poll for completion */
+       ixgbe_fdir_enable_82599(hw, fdirctrl);
+}
+
 /*
  * These defines allow us to quickly generate all of the necessary instructions
  * in the function below by simply calling out IXGBE_COMPUTE_SIG_HASH_ITERATION
@@ -1491,16 +1525,15 @@ u32 ixgbe_atr_compute_sig_hash_82599(union ixgbe_atr_hash_dword input,
  * Note that the tunnel bit in input must not be set when the hardware
  * tunneling support does not exist.
  **/
-s32 ixgbe_fdir_add_signature_filter_82599(struct ixgbe_hw *hw,
-                                         union ixgbe_atr_hash_dword input,
-                                         union ixgbe_atr_hash_dword common,
-                                         u8 queue)
+void ixgbe_fdir_add_signature_filter_82599(struct ixgbe_hw *hw,
+                                          union ixgbe_atr_hash_dword input,
+                                          union ixgbe_atr_hash_dword common,
+                                          u8 queue)
 {
        u64 fdirhashcmd;
        u8 flow_type;
        bool tunnel;
        u32 fdircmd;
-       s32 err;
 
        DEBUGFUNC("ixgbe_fdir_add_signature_filter_82599");
 
@@ -1522,7 +1555,7 @@ s32 ixgbe_fdir_add_signature_filter_82599(struct ixgbe_hw *hw,
                break;
        default:
                DEBUGOUT(" Error on flow type input\n");
-               return IXGBE_ERR_CONFIG;
+               return;
        }
 
        /* configure FDIRCMD register */
@@ -1541,15 +1574,9 @@ s32 ixgbe_fdir_add_signature_filter_82599(struct ixgbe_hw *hw,
        fdirhashcmd |= ixgbe_atr_compute_sig_hash_82599(input, common);
        IXGBE_WRITE_REG64(hw, IXGBE_FDIRHASH, fdirhashcmd);
 
-       err = ixgbe_fdir_check_cmd_complete(hw, &fdircmd);
-       if (err) {
-               DEBUGOUT("Flow Director command did not complete!\n");
-               return err;
-       }
-
        DEBUGOUT2("Tx Queue=%x hash=%x\n", queue, (u32)fdirhashcmd);
 
-       return IXGBE_SUCCESS;
+       return;
 }
 
 #define IXGBE_COMPUTE_BKT_HASH_ITERATION(_n) \
@@ -1804,6 +1831,7 @@ s32 ixgbe_fdir_set_input_mask_82599(struct ixgbe_hw *hw,
                switch (hw->mac.type) {
                case ixgbe_mac_X550:
                case ixgbe_mac_X550EM_x:
+               case ixgbe_mac_X550EM_a:
                        IXGBE_WRITE_REG(hw, IXGBE_FDIRSCTPM, ~fdirtcpm);
                        break;
                default: