ena.c (d209ffee155dd5e505f174a356c8f50c96ebf57e) | ena.c (90232d18ca4f7a5a3073a8279a9b9d3228df5f87) |
---|---|
1/*- 2 * SPDX-License-Identifier: BSD-2-Clause 3 * 4 * Copyright (c) 2015-2021 Amazon.com, Inc. or its affiliates. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 141 unchanged lines hidden (view full) --- 150static int ena_get_dev_offloads(struct ena_com_dev_get_features_ctx *); 151static void ena_update_host_info(struct ena_admin_host_info *, if_t); 152static void ena_update_hwassist(struct ena_adapter *); 153static int ena_setup_ifnet(device_t, struct ena_adapter *, 154 struct ena_com_dev_get_features_ctx *); 155static int ena_enable_wc(device_t, struct resource *); 156static int ena_set_queues_placement_policy(device_t, struct ena_com_dev *, 157 struct ena_admin_feature_llq_desc *, struct ena_llq_configurations *); | 1/*- 2 * SPDX-License-Identifier: BSD-2-Clause 3 * 4 * Copyright (c) 2015-2021 Amazon.com, Inc. or its affiliates. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 141 unchanged lines hidden (view full) --- 150static int ena_get_dev_offloads(struct ena_com_dev_get_features_ctx *); 151static void ena_update_host_info(struct ena_admin_host_info *, if_t); 152static void ena_update_hwassist(struct ena_adapter *); 153static int ena_setup_ifnet(device_t, struct ena_adapter *, 154 struct ena_com_dev_get_features_ctx *); 155static int ena_enable_wc(device_t, struct resource *); 156static int ena_set_queues_placement_policy(device_t, struct ena_com_dev *, 157 struct ena_admin_feature_llq_desc *, struct ena_llq_configurations *); |
158static int ena_map_llq_mem_bar(device_t, struct ena_com_dev *); |
|
158static uint32_t ena_calc_max_io_queue_num(device_t, struct ena_com_dev *, 159 struct ena_com_dev_get_features_ctx *); 160static int ena_calc_io_queue_size(struct ena_calc_queue_size_ctx *); 161static void ena_config_host_info(struct ena_com_dev *, device_t); 162static int ena_attach(device_t); 163static int ena_detach(device_t); 164static int ena_device_init(struct ena_adapter *, device_t, 165 struct ena_com_dev_get_features_ctx *, int *); --- 2400 unchanged lines hidden (view full) --- 2566 return (EOPNOTSUPP); 2567} 2568 2569static int 2570ena_set_queues_placement_policy(device_t pdev, struct ena_com_dev *ena_dev, 2571 struct ena_admin_feature_llq_desc *llq, 2572 struct ena_llq_configurations *llq_default_configurations) 2573{ | 159static uint32_t ena_calc_max_io_queue_num(device_t, struct ena_com_dev *, 160 struct ena_com_dev_get_features_ctx *); 161static int ena_calc_io_queue_size(struct ena_calc_queue_size_ctx *); 162static void ena_config_host_info(struct ena_com_dev *, device_t); 163static int ena_attach(device_t); 164static int ena_detach(device_t); 165static int ena_device_init(struct ena_adapter *, device_t, 166 struct ena_com_dev_get_features_ctx *, int *); --- 2400 unchanged lines hidden (view full) --- 2567 return (EOPNOTSUPP); 2568} 2569 2570static int 2571ena_set_queues_placement_policy(device_t pdev, struct ena_com_dev *ena_dev, 2572 struct ena_admin_feature_llq_desc *llq, 2573 struct ena_llq_configurations *llq_default_configurations) 2574{ |
2574 struct ena_adapter *adapter = device_get_softc(pdev); 2575 int rc, rid; | 2575 int rc; |
2576 uint32_t llq_feature_mask; 2577 2578 llq_feature_mask = 1 << ENA_ADMIN_LLQ; 2579 if (!(ena_dev->supported_features & llq_feature_mask)) { 2580 ena_log(pdev, WARN, 2581 "LLQ is not supported. Fallback to host mode policy.\n"); 2582 ena_dev->tx_mem_queue_type = ENA_ADMIN_PLACEMENT_POLICY_HOST; 2583 return (0); 2584 } 2585 | 2576 uint32_t llq_feature_mask; 2577 2578 llq_feature_mask = 1 << ENA_ADMIN_LLQ; 2579 if (!(ena_dev->supported_features & llq_feature_mask)) { 2580 ena_log(pdev, WARN, 2581 "LLQ is not supported. Fallback to host mode policy.\n"); 2582 ena_dev->tx_mem_queue_type = ENA_ADMIN_PLACEMENT_POLICY_HOST; 2583 return (0); 2584 } 2585 |
2586 if (ena_dev->mem_bar == NULL) { 2587 ena_log(pdev, WARN, 2588 "LLQ is advertised as supported but device doesn't expose mem bar.\n"); 2589 ena_dev->tx_mem_queue_type = ENA_ADMIN_PLACEMENT_POLICY_HOST; 2590 return (0); 2591 } 2592 |
|
2586 rc = ena_com_config_dev_mode(ena_dev, llq, llq_default_configurations); 2587 if (unlikely(rc != 0)) { 2588 ena_log(pdev, WARN, "Failed to configure the device mode. " 2589 "Fallback to host mode policy.\n"); 2590 ena_dev->tx_mem_queue_type = ENA_ADMIN_PLACEMENT_POLICY_HOST; | 2593 rc = ena_com_config_dev_mode(ena_dev, llq, llq_default_configurations); 2594 if (unlikely(rc != 0)) { 2595 ena_log(pdev, WARN, "Failed to configure the device mode. " 2596 "Fallback to host mode policy.\n"); 2597 ena_dev->tx_mem_queue_type = ENA_ADMIN_PLACEMENT_POLICY_HOST; |
2591 return (0); | |
2592 } 2593 | 2598 } 2599 |
2594 /* Nothing to config, exit */ 2595 if (ena_dev->tx_mem_queue_type == ENA_ADMIN_PLACEMENT_POLICY_HOST) 2596 return (0); | 2600 return (0); 2601} |
2597 | 2602 |
2603static int 2604ena_map_llq_mem_bar(device_t pdev, struct ena_com_dev *ena_dev) 2605{ 2606 struct ena_adapter *adapter = device_get_softc(pdev); 2607 int rc, rid; 2608 |
|
2598 /* Try to allocate resources for LLQ bar */ 2599 rid = PCIR_BAR(ENA_MEM_BAR); 2600 adapter->memory = bus_alloc_resource_any(pdev, SYS_RES_MEMORY, 2601 &rid, RF_ACTIVE); 2602 if (unlikely(adapter->memory == NULL)) { 2603 ena_log(pdev, WARN, "unable to allocate LLQ bar resource. " 2604 "Fallback to host mode policy.\n"); 2605 ena_dev->tx_mem_queue_type = ENA_ADMIN_PLACEMENT_POLICY_HOST; --- 984 unchanged lines hidden (view full) --- 3590 if (unlikely(rc != 0)) { 3591 ena_log(pdev, ERR, "ENA device init failed! (err: %d)\n", rc); 3592 rc = ENXIO; 3593 goto err_bus_free; 3594 } 3595 3596 set_default_llq_configurations(&llq_config, &get_feat_ctx.llq); 3597 | 2609 /* Try to allocate resources for LLQ bar */ 2610 rid = PCIR_BAR(ENA_MEM_BAR); 2611 adapter->memory = bus_alloc_resource_any(pdev, SYS_RES_MEMORY, 2612 &rid, RF_ACTIVE); 2613 if (unlikely(adapter->memory == NULL)) { 2614 ena_log(pdev, WARN, "unable to allocate LLQ bar resource. " 2615 "Fallback to host mode policy.\n"); 2616 ena_dev->tx_mem_queue_type = ENA_ADMIN_PLACEMENT_POLICY_HOST; --- 984 unchanged lines hidden (view full) --- 3601 if (unlikely(rc != 0)) { 3602 ena_log(pdev, ERR, "ENA device init failed! (err: %d)\n", rc); 3603 rc = ENXIO; 3604 goto err_bus_free; 3605 } 3606 3607 set_default_llq_configurations(&llq_config, &get_feat_ctx.llq); 3608 |
3609 rc = ena_map_llq_mem_bar(pdev, ena_dev); 3610 if (unlikely(rc != 0)) { 3611 ena_log(pdev, ERR, "failed to map ENA mem bar"); 3612 goto err_com_free; 3613 } 3614 |
|
3598 rc = ena_set_queues_placement_policy(pdev, ena_dev, &get_feat_ctx.llq, 3599 &llq_config); 3600 if (unlikely(rc != 0)) { 3601 ena_log(pdev, ERR, "failed to set placement policy\n"); 3602 goto err_com_free; 3603 } 3604 3605 if (ena_dev->tx_mem_queue_type == ENA_ADMIN_PLACEMENT_POLICY_DEV) --- 337 unchanged lines hidden --- | 3615 rc = ena_set_queues_placement_policy(pdev, ena_dev, &get_feat_ctx.llq, 3616 &llq_config); 3617 if (unlikely(rc != 0)) { 3618 ena_log(pdev, ERR, "failed to set placement policy\n"); 3619 goto err_com_free; 3620 } 3621 3622 if (ena_dev->tx_mem_queue_type == ENA_ADMIN_PLACEMENT_POLICY_DEV) --- 337 unchanged lines hidden --- |