Thu Jun 25 06:45:10 2020 UTC ()
 Use unsigned to avoid undefined behavior in ixgbe_fc_enable_generic().
Same as ixgbe_common.c rev. 1.24. Found by KUBSan.


(msaitoh)
diff -r1.14 -r1.15 src/sys/dev/pci/ixgbe/ixgbe_82598.c

cvs diff -r1.14 -r1.15 src/sys/dev/pci/ixgbe/ixgbe_82598.c (expand / switch to unified diff)

--- src/sys/dev/pci/ixgbe/ixgbe_82598.c 2020/01/03 12:59:46 1.14
+++ src/sys/dev/pci/ixgbe/ixgbe_82598.c 2020/06/25 06:45:10 1.15
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ixgbe_82598.c,v 1.14 2020/01/03 12:59:46 pgoyette Exp $ */ 1/* $NetBSD: ixgbe_82598.c,v 1.15 2020/06/25 06:45:10 msaitoh Exp $ */
2 2
3/****************************************************************************** 3/******************************************************************************
4 SPDX-License-Identifier: BSD-3-Clause 4 SPDX-License-Identifier: BSD-3-Clause
5 5
6 Copyright (c) 2001-2017, Intel Corporation 6 Copyright (c) 2001-2017, Intel Corporation
7 All rights reserved. 7 All rights reserved.
8 8
9 Redistribution and use in source and binary forms, with or without 9 Redistribution and use in source and binary forms, with or without
10 modification, are permitted provided that the following conditions are met: 10 modification, are permitted provided that the following conditions are met:
11 11
12 1. Redistributions of source code must retain the above copyright notice, 12 1. Redistributions of source code must retain the above copyright notice,
13 this list of conditions and the following disclaimer. 13 this list of conditions and the following disclaimer.
14 14
@@ -528,27 +528,27 @@ s32 ixgbe_fc_enable_82598(struct ixgbe_h @@ -528,27 +528,27 @@ s32 ixgbe_fc_enable_82598(struct ixgbe_h
528 hw->fc.high_water[i]) { 528 hw->fc.high_water[i]) {
529 fcrtl = (hw->fc.low_water[i] << 10) | IXGBE_FCRTL_XONE; 529 fcrtl = (hw->fc.low_water[i] << 10) | IXGBE_FCRTL_XONE;
530 fcrth = (hw->fc.high_water[i] << 10) | IXGBE_FCRTH_FCEN; 530 fcrth = (hw->fc.high_water[i] << 10) | IXGBE_FCRTH_FCEN;
531 IXGBE_WRITE_REG(hw, IXGBE_FCRTL(i), fcrtl); 531 IXGBE_WRITE_REG(hw, IXGBE_FCRTL(i), fcrtl);
532 IXGBE_WRITE_REG(hw, IXGBE_FCRTH(i), fcrth); 532 IXGBE_WRITE_REG(hw, IXGBE_FCRTH(i), fcrth);
533 } else { 533 } else {
534 IXGBE_WRITE_REG(hw, IXGBE_FCRTL(i), 0); 534 IXGBE_WRITE_REG(hw, IXGBE_FCRTL(i), 0);
535 IXGBE_WRITE_REG(hw, IXGBE_FCRTH(i), 0); 535 IXGBE_WRITE_REG(hw, IXGBE_FCRTH(i), 0);
536 } 536 }
537 537
538 } 538 }
539 539
540 /* Configure pause time (2 TCs per register) */ 540 /* Configure pause time (2 TCs per register) */
541 reg = hw->fc.pause_time * 0x00010001; 541 reg = (u32)hw->fc.pause_time * 0x00010001;
542 for (i = 0; i < (IXGBE_DCB_MAX_TRAFFIC_CLASS / 2); i++) 542 for (i = 0; i < (IXGBE_DCB_MAX_TRAFFIC_CLASS / 2); i++)
543 IXGBE_WRITE_REG(hw, IXGBE_FCTTV(i), reg); 543 IXGBE_WRITE_REG(hw, IXGBE_FCTTV(i), reg);
544 544
545 /* Configure flow control refresh threshold value */ 545 /* Configure flow control refresh threshold value */
546 IXGBE_WRITE_REG(hw, IXGBE_FCRTV, hw->fc.pause_time / 2); 546 IXGBE_WRITE_REG(hw, IXGBE_FCRTV, hw->fc.pause_time / 2);
547 547
548out: 548out:
549 return ret_val; 549 return ret_val;
550} 550}
551 551
552/** 552/**
553 * ixgbe_start_mac_link_82598 - Configures MAC link settings 553 * ixgbe_start_mac_link_82598 - Configures MAC link settings
554 * @hw: pointer to hardware structure 554 * @hw: pointer to hardware structure